From 5573973ca342981d773ecab7dac75546082d42c0 Mon Sep 17 00:00:00 2001 From: Jason Poon Date: Wed, 10 Jan 2018 12:01:27 -0800 Subject: [PATCH] fix: no need to change cursor if there is no active editor. closes #2273 --- extension.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/extension.ts b/extension.ts index 72264ab6465..d871f82f57a 100644 --- a/extension.ts +++ b/extension.ts @@ -71,14 +71,12 @@ export async function getAndUpdateModeHandler(): Promise { // 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; }