make implementation of 'di<symbol>' more robust (we check if the cursor is inside a symbol-pair before checking if there is a symbol pair after the cursor), and add tests for 'di<symbol>' motion
This commit is contained in:
@@ -5075,6 +5075,82 @@ struct
|
||||
end)
|
||||
]
|
||||
|
||||
val diParenDelete = describe "delete motion 'di('"
|
||||
[ test "does not delete when there is no ( after the cursor" (fn _ =>
|
||||
let
|
||||
(* arrange *)
|
||||
val originalString = " ( ) hello\n"
|
||||
val app = TestUtils.init originalString
|
||||
val app = AppWith.idx (app, 7)
|
||||
|
||||
(* act *)
|
||||
val {buffer, ...} = TestUtils.updateMany (app, "di(")
|
||||
|
||||
(* assert *)
|
||||
val expectedString = originalString
|
||||
val actualString = LineGap.toString buffer
|
||||
in
|
||||
Expect.isTrue (expectedString = actualString)
|
||||
end)
|
||||
, test
|
||||
"deletes pair after cursor when there is a pair \
|
||||
\before the cursor and after the cursor"
|
||||
(fn _ =>
|
||||
let
|
||||
(* arrange *)
|
||||
val originalString = " ( abc ) xyz ( def )\n"
|
||||
val app = TestUtils.init originalString
|
||||
val app = AppWith.idx (app, 9)
|
||||
|
||||
(* act *)
|
||||
val {buffer, ...} = TestUtils.updateMany (app, "di(")
|
||||
|
||||
(* assert *)
|
||||
val expectedString = " ( abc ) xyz ()\n"
|
||||
val actualString = LineGap.toString buffer
|
||||
in
|
||||
Expect.isTrue (expectedString = actualString)
|
||||
end)
|
||||
, test
|
||||
"deletes inside outer parens when cursor is in \
|
||||
\outer paren, and there is an inner paren after cursor"
|
||||
(fn _ =>
|
||||
let
|
||||
(* arrange *)
|
||||
val originalString = "( ( hello ) )\n"
|
||||
val app = TestUtils.init originalString
|
||||
val app = AppWith.idx (app, 1)
|
||||
|
||||
(* act *)
|
||||
val {buffer, ...} = TestUtils.updateMany (app, "di(")
|
||||
|
||||
(* assert *)
|
||||
val expectedString = "()\n"
|
||||
val actualString = LineGap.toString buffer
|
||||
in
|
||||
Expect.isTrue (expectedString = actualString)
|
||||
end)
|
||||
, test
|
||||
"deletes inside inner parren when cursor is in inner paren-pair, \
|
||||
\and there is an outer paren above this inner paren"
|
||||
(fn _ =>
|
||||
let
|
||||
(* arrange *)
|
||||
val originalString = "( ( hello ) )\n"
|
||||
val app = TestUtils.init originalString
|
||||
val app = AppWith.idx (app, 5)
|
||||
|
||||
(* act *)
|
||||
val {buffer, ...} = TestUtils.updateMany (app, "di(")
|
||||
|
||||
(* assert *)
|
||||
val expectedString = "( () )\n"
|
||||
val actualString = LineGap.toString buffer
|
||||
in
|
||||
Expect.isTrue (expectedString = actualString)
|
||||
end)
|
||||
]
|
||||
|
||||
val tests =
|
||||
[ dhDelete
|
||||
, dlDelete
|
||||
@@ -5105,5 +5181,6 @@ struct
|
||||
, dawDelete
|
||||
, daWDelete
|
||||
, pairDelete
|
||||
, diParenDelete
|
||||
]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user