From f57f33258cf94b0ebfbdea0d9a0a48ebc37bc08e Mon Sep 17 00:00:00 2001 From: nosami Date: Thu, 20 Apr 2017 02:35:23 +0100 Subject: [PATCH] Don't reset state when running goto def --- XSVim/XSVim.fs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/XSVim/XSVim.fs b/XSVim/XSVim.fs index bef85e1..78e5b25 100755 --- a/XSVim/XSVim.fs +++ b/XSVim/XSVim.fs @@ -1,5 +1,6 @@ namespace XSVim open System +open System.Collections.Generic open MonoDevelop.Core open MonoDevelop.Ide.Commands open MonoDevelop.Ide.Editor @@ -727,15 +728,19 @@ module Vim = type XSVim() = inherit TextEditorExtension() - let mutable vimState = { keys=[]; mode=NormalMode; visualStartOffset=0; findCharCommand=None; lastAction=[]; clipboard="" } + static let editorStates = Dictionary() - override x.Initialize() = EditActions.SwitchCaretMode x.Editor + override x.Initialize() = + if not (editorStates.ContainsKey x.Editor.FileName) then + editorStates.Add(x.Editor.FileName, { keys=[]; mode=NormalMode; visualStartOffset=0; findCharCommand=None; lastAction=[]; clipboard="" }) + EditActions.SwitchCaretMode x.Editor override x.KeyPress descriptor = + let vimState = editorStates.[x.Editor.FileName] let oldState = vimState let newState, handledKeyPress = Vim.handleKeyPress vimState descriptor x.Editor - vimState <- newState + editorStates.[x.Editor.FileName] <- newState match oldState.mode with | InsertMode -> base.KeyPress descriptor | VisualMode -> false