mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-26 03:33:58 -05:00
Fixed editor tab key not handle correctly on multiple lines selections
This commit is contained in:
parent
2501b190ab
commit
1b059775e5
1 changed files with 6 additions and 3 deletions
|
@ -27,18 +27,21 @@ var defaultExtraKeys = {
|
||||||
var line = cm.getLine(cursor.line);
|
var line = cm.getLine(cursor.line);
|
||||||
var regex = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))/;
|
var regex = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))/;
|
||||||
var match;
|
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 ch = match[1].length;
|
||||||
var pos = {
|
var pos = {
|
||||||
line: cursor.line,
|
line: cursor.line,
|
||||||
ch: ch
|
ch: ch
|
||||||
};
|
};
|
||||||
if (editor.getOption('indentWithTabs'))
|
if (cm.getOption('indentWithTabs'))
|
||||||
cm.replaceRange(tab, pos, pos, '+input');
|
cm.replaceRange(tab, pos, pos, '+input');
|
||||||
else
|
else
|
||||||
cm.replaceRange(spaces, pos, pos, '+input');
|
cm.replaceRange(spaces, pos, pos, '+input');
|
||||||
} else {
|
} else {
|
||||||
if (editor.getOption('indentWithTabs'))
|
if (cm.getOption('indentWithTabs'))
|
||||||
cm.execCommand('defaultTab');
|
cm.execCommand('defaultTab');
|
||||||
else {
|
else {
|
||||||
cm.replaceSelection(spaces);
|
cm.replaceSelection(spaces);
|
||||||
|
|
Loading…
Reference in a new issue