Skip to content

Commit

Permalink
Fix: Weird cursor behavior with lists (#2519)
Browse files Browse the repository at this point in the history
* works but messes up the undo buffer

* fix executeEdits

* use a single promise
  • Loading branch information
codebykat authored Dec 11, 2020
1 parent 78acc9d commit 8dd44e2
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/note-content-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -993,15 +993,24 @@ class NoteContentEditor extends Component<Props> {
lineNumber: lineNumber + 1,
});

const range = new this.monaco.Range(lineNumber, 0, lineNumber + 1, 0);
const range = new this.monaco.Range(
lineNumber,
0,
lineNumber + 1,
thisLine.length + 1
);
const identifier = { major: 1, minor: 1 };
const op = { identifier, range, text: '', forceMoveMarkers: true };
this.editor.executeEdits('autolist', [op]);
const op = { identifier, range, text: null, forceMoveMarkers: true };

return (
value.slice(0, Math.max(0, prevLineStart - 1)) +
value.slice(thisLineStart)
);
Promise.resolve().then(() => {
this.editor.executeEdits('autolist', [op]);
this.editor.setPosition({
column: 0,
lineNumber: lineNumber,
});
});

return;
}

const lineStart = model.getOffsetAt({
Expand Down

0 comments on commit 8dd44e2

Please sign in to comment.