diff --git a/CHANGELOG.md b/CHANGELOG.md index 7154c6e..86ff06f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The format is based on to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Now scrolls the window so that the cursor is always visible except when there are multiple cursors + +## [1.1.0] - 2018-09-24 ### Added - Multi-cursor support - New command `extension.deleteWordRight` with keyboard shortcut Ctrl+Delete diff --git a/src/extension.ts b/src/extension.ts index 50a3fa5..cb888be 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -77,6 +77,9 @@ export function cursorNextWordEndJa( editor.selections = editor.selections .map(s => positionOfNextWordEnd(document, s.active, wordSeparators)) .map(p => new Selection(p, p)); + if (editor.selections.length === 1) { + editor.revealRange(editor.selection); + } } export function cursorNextWordEndSelectJa( @@ -88,6 +91,9 @@ export function cursorNextWordEndSelectJa( s.anchor, positionOfNextWordEnd(editor.document, s.active, wordSeparators)) ); + if (editor.selections.length === 1) { + editor.revealRange(editor.selection); + } } export function cursorPrevWordStartJa( @@ -98,6 +104,9 @@ export function cursorPrevWordStartJa( editor.selections = editor.selections .map(s => positionOfPrevWordStart(document, s.active, wordSeparators)) .map(p => new Selection(p, p)); + if (editor.selections.length === 1) { + editor.revealRange(editor.selection); + } } export function cursorPrevWordStartSelectJa( @@ -109,6 +118,9 @@ export function cursorPrevWordStartSelectJa( s.anchor, positionOfPrevWordStart(editor.document, s.active, wordSeparators) )); + if (editor.selections.length === 1) { + editor.revealRange(editor.selection); + } } export function deleteWordRight( @@ -125,6 +137,10 @@ export function deleteWordRight( for (let selection of selections) { e.delete(selection); } + }).then(() => { + if (editor.selections.length === 1) { + editor.revealRange(editor.selection); + } }); } @@ -142,6 +158,10 @@ export function deleteWordLeft( for (let selection of selections) { e.delete(selection); } + }).then(() => { + if (editor.selections.length === 1) { + editor.revealRange(editor.selection); + } }); }