Skip to content

Commit

Permalink
Don't reset state when running goto def
Browse files Browse the repository at this point in the history
  • Loading branch information
nosami committed Apr 20, 2017
1 parent e6f20ba commit f57f332
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions XSVim/XSVim.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace XSVim
open System
open System.Collections.Generic
open MonoDevelop.Core
open MonoDevelop.Ide.Commands
open MonoDevelop.Ide.Editor
Expand Down Expand Up @@ -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<FilePath, VimState>()

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
Expand Down

0 comments on commit f57f332

Please sign in to comment.