Skip to content

Commit

Permalink
Fixes hang when switching branch / making large text changes
Browse files Browse the repository at this point in the history
Don't concat action list for each changed character

Fixes #233
  • Loading branch information
nosami committed Dec 15, 2018
1 parent ef1f7b4 commit 94cd956
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions XSVim.Tests/MiscTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ module ``Miscellaneous tests`` =
System.Collections$
"""

[<Test>]
let ``Large text addition is not too slow!``() =
let _, state, editor =
test " $" ""
editor.InsertText(0, new System.String('x', 200000))

[<Test>]
let ``backspace is repeated``() =
assertText "d$" "iabc<bs> <esc>." "abab $ d"
Expand Down
9 changes: 6 additions & 3 deletions XSVim/Addin.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ module Subscriptions =

let newState = { state with lastAction = actions }
Vim.editorStates.[editor.FileName] <- newState

if change.Offset + change.InsertionLength = editor.CaretOffset then
let state = Vim.editorStates.[editor.FileName]
let typedChars =
[ for c in change.InsertedText.Text do
yield typeChar (Key c) ]
let vimState =
change.InsertedText.Text
|> Seq.fold(fun state c ->
{ state with lastAction = state.lastAction @ [ typeChar (Key c) ]}) (Vim.editorStates.[editor.FileName])
{ state with lastAction = state.lastAction @ typedChars }
Vim.editorStates.[editor.FileName] <- vimState

type XSVim() as this =
Expand Down
2 changes: 1 addition & 1 deletion XSVim/Properties/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open System.Runtime.CompilerServices
[<AutoOpen>]
module AddinVersion =
[<Literal>]
let version = "0.64.4.76"
let version = "0.64.5.76"

[<assembly: AssemblyTitle("XSVim")>]
// The assembly version has the format {Major}.{Minor}.{Build}.{Revision}
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mono "/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/vstool.exe" run-md-tests XSVim.Tests/bin/Debug/XSVim.Tests.dll
mono "/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/vstool.exe" run-md-tests XSVim.Tests/bin/Debug/XSVim.Tests.dll -labels

0 comments on commit 94cd956

Please sign in to comment.