From db86dc7a4880ea59b5647dad417fad6379e46b9a Mon Sep 17 00:00:00 2001 From: Cheng-Han, Wu Date: Tue, 16 Feb 2016 09:55:51 -0600 Subject: Support textcomplete in multiple editing --- .../vendor/jquery-textcomplete/jquery.textcomplete.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'public') 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(); }, -- cgit v1.2.3