Skip to content

Commit

Permalink
Fixes x with repeat paste buffer. Fixes #217 and #212
Browse files Browse the repository at this point in the history
  • Loading branch information
nosami committed May 7, 2018
1 parent 72b8e9c commit 873c04e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions XSVim.Tests/YankAndPut.fs
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ module ``Yank and put tests`` =
[<Test>]
let ``Multi line put on line without delimiter places caret at top line of paste``() =
assertText "aa$a\nbbb\nccc" "Vjdp" "ccc\na$aa\nbbb"

[<Test>]
let ``x with multiplier stops at EOL``() =
assertText "ab$cdef\n" "100xp" "abcdef$\n"
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.54.6"
let version = "0.54.7"

[<assembly: AssemblyTitle("XSVim")>]
// The assembly version has the format {Major}.{Minor}.{Build}.{Revision}
Expand Down
3 changes: 2 additions & 1 deletion XSVim/Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ type VimKey =
| EscapeKey c -> string c
| Key c -> string c

type Repeat = int

type TextObject =
| Jump of Jump
| Character
| Character of Repeat
| AWord
| InnerWord
| AWORD
Expand Down
6 changes: 5 additions & 1 deletion XSVim/XSVim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ module VimHelpers =
else
editor.CaretOffset
| EndOfLine -> editor.CaretOffset, line.EndOffset-1
| Character repeat ->
let line = editor.GetLine editor.CaretLine
let endOffset = min line.EndOffset (editor.CaretOffset + repeat)
editor.CaretOffset, endOffset
| EndOfLineIncludingDelimiter ->
editor.CaretOffset,
if eofOnLine line then
Expand Down Expand Up @@ -1516,7 +1520,7 @@ module Vim =
| None -> [ runOnce (Yank EmptyRegister) WholeLineIncludingDelimiter ]
| NormalMode, [ "C" ] -> [ run Change EndOfLine ]
| NormalMode, [ "D" ] -> [ run Delete EndOfLine ]
| NormalMode, [ "x" ] -> [ run Delete CurrentLocation ]
| NormalMode, [ "x" ] -> [ runOnce Delete (Character (numericArgument |> Option.defaultValue 1)) ]
| NormalMode, [ "X" ] -> [ run DeleteLeft Nothing ]
| NormalMode, [ "s"] -> [ run Substitute CurrentLocation]
| NormalMode, [ "S"] -> [ run Delete WholeLineIncludingDelimiter; runOnce (InsertLine After) Nothing; switchMode InsertMode ]
Expand Down

0 comments on commit 873c04e

Please sign in to comment.