Skip to content

Commit

Permalink
Merge pull request #36 from WebCoder49/fix-enter-selection
Browse files Browse the repository at this point in the history
Remove selections after ENTER, so caret doesn't select new text. #35
  • Loading branch information
WebCoder49 committed Apr 27, 2023
2 parents d88a382 + 89fad58 commit 3c2455a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions plugins/indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,12 @@

// save the current cursor position
let selection_start = input_element.selectionStart;
let selection_end = input_element.selectionEnd;

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

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

codeInput.update(input_element.value);

Expand All @@ -151,4 +150,4 @@
input_element.scrollTop += 20; // px
}
}
}
}

0 comments on commit 3c2455a

Please sign in to comment.