Skip to content

Commit

Permalink
Ex-mode line delete (:1,3d)
Browse files Browse the repository at this point in the history
Fixes #221. Re #68 #42
  • Loading branch information
nosami committed May 15, 2018
1 parent 49ef664 commit d5cde5f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
14 changes: 14 additions & 0 deletions XSVim.Tests/ExModeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,17 @@ module ``Ex mode tests`` =
let ``Could not parse message is reset``() =
let _, state, _ = test "a$bc" ":garbage<ret>l"
state.statusMessage |> should equal None

[<Test>]
let ``Deletes lines 2 to 4``() =
assertText
"""11111
22222
33333
44444
55555$"""

":2,4d<ret>"

"""11111
5$5555"""
13 changes: 13 additions & 0 deletions XSVim/ExMode.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ module exMode =
else
None

let (|DeleteLines|_|) input =
let matches = Regex.Matches(input, "([\d+]),([\d+])d", RegexOptions.Compiled)
if matches.Count = 1 then
let m = matches.[0]
Some (int m.Groups.[1].Value, int m.Groups.[2].Value)
else
None

let processKey (state:VimState) (key:KeyDescriptor) =
let setMessage message = { state with statusMessage = message }
let normalMode = { state with statusMessage = None; mode = NormalMode }
Expand Down Expand Up @@ -119,6 +127,11 @@ module exMode =
[ runOnce Move (Jump (ToMark (startMarker, MarkerJumpType.StartOfLine)))
runOnce DeleteWholeLines (Jump (ToMark (endMarker, MarkerJumpType.StartOfLine))) ]
normalMode, actions
| DeleteLines (startLine, endLine) ->
let actions =
[ runOnce Move (Jump (StartOfLineNumber startLine))
runOnce DeleteWholeLines (Jump (StartOfLineNumber endLine)) ]
normalMode, actions
| _ ->
{ state with statusMessage = sprintf "Could not parse :%s" rest |> Some; mode = NormalMode; }
, resetKeys
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.58.0"
let version = "0.59.0"

[<assembly: AssemblyTitle("XSVim")>]
// The assembly version has the format {Major}.{Minor}.{Build}.{Revision}
Expand Down

0 comments on commit d5cde5f

Please sign in to comment.