summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-02-16 09:54:33 -0600
committerCheng-Han, Wu2016-02-16 09:54:33 -0600
commit1b059775e56f74967925abf93d4da1e4a0ae8802 (patch)
tree813cc08c4ffbcdd25cf868195fec080dfdd2bd92
parent2501b190ab16ba997557537725df4633b7e96e02 (diff)
Fixed editor tab key not handle correctly on multiple lines selections
-rw-r--r--public/js/index.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/public/js/index.js b/public/js/index.js
index 5773a001..6fbdd517 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -27,18 +27,21 @@ var defaultExtraKeys = {
var line = cm.getLine(cursor.line);
var regex = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))/;
var match;
- if ((match = regex.exec(line)) !== null) {
+ var multiple = cm.getSelection().split('\n').length > 1 || cm.getSelections().length > 1;
+ if (multiple) {
+ cm.execCommand('defaultTab');
+ } else if ((match = regex.exec(line)) !== null) {
var ch = match[1].length;
var pos = {
line: cursor.line,
ch: ch
};
- if (editor.getOption('indentWithTabs'))
+ if (cm.getOption('indentWithTabs'))
cm.replaceRange(tab, pos, pos, '+input');
else
cm.replaceRange(spaces, pos, pos, '+input');
} else {
- if (editor.getOption('indentWithTabs'))
+ if (cm.getOption('indentWithTabs'))
cm.execCommand('defaultTab');
else {
cm.replaceSelection(spaces);