Skip to content

Commit

Permalink
Merge pull request #22 from k4a-l/fix-move-cursor-to-end-of-line-when…
Browse files Browse the repository at this point in the history
…-decrease-shift

fix: move cursor to end of line when decrease shift
  • Loading branch information
k4a-l authored Sep 18, 2024
2 parents bf8d85a + 6f2b1dd commit 51d7d0d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/features/shiftHeading/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ export class DecreaseHeading implements EditorOperation {
return true;
}

const isOneline =
editor.getCursor("from").line === editor.getCursor("to").line;

// Dispatch Transaction
const editorChange = composeLineChanges(
editor,
Expand All @@ -109,6 +112,11 @@ export class DecreaseHeading implements EditorOperation {
editor.transaction({
changes: editorChange,
});

// If only one line is targeted, move the cursor to the end of the line.
if (isOneline) {
editor.setCursor(editor.getCursor("anchor").line);
}
return editorChange.length ? true : false;
};

Expand Down

0 comments on commit 51d7d0d

Please sign in to comment.