Skip to content

Commit 3c2455a

Browse files
authored
Merge pull request #36 from WebCoder49/fix-enter-selection
Remove selections after ENTER, so caret doesn't select new text. #35
2 parents d88a382 + 89fad58 commit 3c2455a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

plugins/indent.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,12 @@
129129

130130
// save the current cursor position
131131
let selection_start = input_element.selectionStart;
132-
let selection_end = input_element.selectionEnd;
133132

134133
document.execCommand("insertText", false, "\n" + new_line); // Write new line, including auto-indentation
135134

136135
// move cursor to new position
137136
input_element.selectionStart = selection_start + number_indents + 1; // count the indent level and the newline character
138-
input_element.selectionEnd = selection_end + number_indents + 1;
137+
input_element.selectionEnd = selection_start + number_indents + 1;
139138

140139
codeInput.update(input_element.value);
141140

@@ -151,4 +150,4 @@
151150
input_element.scrollTop += 20; // px
152151
}
153152
}
154-
}
153+
}

0 commit comments

Comments
 (0)