1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-21 23:17:42 +02:00

Desktop: Resolves #4750 Disappearing text in markdown editor (#4781)

Fixes #4750 by preventing automatic deletion of list elements in certain cases
This commit is contained in:
Adarsh Singh
2021-04-02 09:09:42 +05:30
committed by GitHub
parent 829a245858
commit f59e312ee2
6 changed files with 107 additions and 2 deletions

View File

@ -155,14 +155,18 @@ export default function useListIdent(CodeMirror: any) {
// otherwise fallback on the default codemirror behavior
if (ranges.length === 1) {
const line = cm.getLine(anchor.line);
// if cursor on 0th line set previousLine=''
const previousLine = anchor.line ? cm.getLine(anchor.line - 1) : '';
if (markdownUtils.isEmptyListItem(line)) {
const tokens = cm.getLineTokens(anchor.line);
// A empty list item with an indent will have whitespace as the first token
if (tokens.length > 1 && tokens[0].string.match(/^\s/)) {
cm.execCommand('smartListUnindent');
} else {
} else if (markdownUtils.isListItem(previousLine)) {
cm.replaceRange('', { line: anchor.line, ch: 0 }, anchor);
} else { // perform normal enter key operation
cm.replaceRange('\n', anchor);
}
return;
}