Skip to content

Commit 5799bb1

Browse files
committed
Move indent plugin's checkEnter to beforeinput, so Enter keydown can be defaultPrevented
1 parent be51c65 commit 5799bb1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plugins/indent.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ codeInput.plugins.Indent = class extends codeInput.Plugin {
6060

6161
let textarea = codeInput.textareaElement;
6262
textarea.addEventListener('focus', (event) => { if(this.escTabToChangeFocus) codeInput.setKeyboardNavInstructions(this.instructions.tabForIndentation, true); })
63-
textarea.addEventListener('keydown', (event) => { this.checkTab(codeInput, event); this.checkEnter(codeInput, event); this.checkBackspace(codeInput, event); });
64-
textarea.addEventListener('beforeinput', (event) => { this.checkCloseBracket(codeInput, event); });
63+
textarea.addEventListener('keydown', (event) => { this.checkTab(codeInput, event); this.checkBackspace(codeInput, event); });
64+
textarea.addEventListener('beforeinput', (event) => { this.checkEnter(codeInput, event); this.checkCloseBracket(codeInput, event); });
6565

6666
// Get the width of the indentation in pixels
6767
let testIndentationWidthPre = document.createElement("pre");
@@ -205,7 +205,7 @@ codeInput.plugins.Indent = class extends codeInput.Plugin {
205205
/* Deal with new lines retaining indentation */
206206
checkEnter(codeInput, event) {
207207
if(codeInput.pluginData.indent.automatedKeypresses) return;
208-
if(event.key != "Enter") {
208+
if(event.inputType != "insertLineBreak" && event.data != "\n") {
209209
return;
210210
}
211211
event.preventDefault(); // Stop normal \n only

0 commit comments

Comments
 (0)