Skip to content

Commit

Permalink
fix: no need to change cursor if there is no active editor. closes #2273
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoon committed Jan 10, 2018
1 parent 50eb928 commit 5573973
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ export async function getAndUpdateModeHandler(): Promise<ModeHandler> {
// Temporary workaround for vscode bug not changing cursor style properly
// https://github.com/Microsoft/vscode/issues/17472
// https://github.com/Microsoft/vscode/issues/17513
const desiredStyle = curHandler.vimState.editor.options.cursorStyle;
if (curHandler.vimState.editor) {
const desiredStyle = curHandler.vimState.editor.options.cursorStyle;

// Temporarily change to any other cursor style besides the desired type, then change back
if (desiredStyle === vscode.TextEditorCursorStyle.Block) {
curHandler.vimState.editor.options.cursorStyle = vscode.TextEditorCursorStyle.Line;
curHandler.vimState.editor.options.cursorStyle = desiredStyle;
} else {
curHandler.vimState.editor.options.cursorStyle = vscode.TextEditorCursorStyle.Block;
// Temporarily change to any other cursor style besides the desired type, then change back
let tempStyle = (desiredStyle || vscode.TextEditorCursorStyle.Line) % 6 + 1;
curHandler.vimState.editor.options.cursorStyle = tempStyle;
curHandler.vimState.editor.options.cursorStyle = desiredStyle;
}

Expand Down

0 comments on commit 5573973

Please sign in to comment.