diff options
author | Cheng-Han, Wu | 2016-02-16 09:55:51 -0600 |
---|---|---|
committer | Cheng-Han, Wu | 2016-02-16 09:55:51 -0600 |
commit | db86dc7a4880ea59b5647dad417fad6379e46b9a (patch) | |
tree | 883aac8f70aae9c1af23dddf6ca3d67e92c55524 /public/vendor | |
parent | 1b059775e56f74967925abf93d4da1e4a0ae8802 (diff) |
Support textcomplete in multiple editing
Diffstat (limited to 'public/vendor')
-rwxr-xr-x | public/vendor/jquery-textcomplete/jquery.textcomplete.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/public/vendor/jquery-textcomplete/jquery.textcomplete.js b/public/vendor/jquery-textcomplete/jquery.textcomplete.js index 49881ce1..485214d5 100755 --- a/public/vendor/jquery-textcomplete/jquery.textcomplete.js +++ b/public/vendor/jquery-textcomplete/jquery.textcomplete.js @@ -968,7 +968,24 @@ if (typeof jQuery === 'undefined') { pre = match[0]; var newSubstr = strategy.replace(value); newSubstr = pre.replace(strategy.match, newSubstr); - editor.replaceRange(newSubstr, {line:cursor.line, ch:match.index}, {line:cursor.line, ch:match.index + match[0].length}, "+input"); + + editor.operation(function() { + var selections = editor.listSelections(); + var bias = match.index - cursor.ch; + for (var i = 0, l = selections.length; i < l; i++) { + var sel = selections[i]; + var start = { + line: sel.head.line, + ch: sel.head.ch + bias + }; + var end = { + line: sel.head.line, + ch: sel.head.ch + bias + match[0].length + }; + editor.replaceRange(newSubstr, start, end, "+input"); + } + }); + if(strategy.done) strategy.done(); }, |