Skip to content

Commit 2f15178

Browse files
authored
Desktop: Remove auto-indent for in note html/xml for Code Mirror (#3374)
html/xml inside of a codeblock will still benefit from auto-indent
1 parent a4b13be commit 2f15178

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ElectronClient/gui/NoteEditor/NoteBody/CodeMirror/utils/useListIdent.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,15 @@ export default function useListIdent(CodeMirror: any) {
126126
cm.replaceRange('', { line: anchor.line, ch: 0 }, anchor);
127127
}
128128
} else {
129-
cm.execCommand('newlineAndIndentContinueMarkdownList');
129+
// Disable automatic indent for html/xml outside of codeblocks
130+
const state = cm.getTokenAt(anchor).state;
131+
const mode = cm.getModeAt(anchor);
132+
// html/xml inside of a codeblock is fair game for auto-indent
133+
if (mode.name !== 'xml' || state.overlay.codeBlock) {
134+
cm.execCommand('newlineAndIndentContinueMarkdownList');
135+
} else {
136+
cm.replaceSelection('\n');
137+
}
130138
}
131139
}
132140
};

0 commit comments

Comments
 (0)