Skip to content

Commit e70a3bf

Browse files
committed
Modify tests to account for end of line spaces
1 parent 1134bae commit e70a3bf

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

src/changes.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct Entry
6161
end
6262

6363

64-
Entry(s::String) = Entry(freeze(testbuf("|")))
64+
Entry(s::String) = Entry(freeze(VimBuffer()))
6565
# entry where both `prev` and `next` reference itself
6666
function Entry(record::BufferRecord)
6767
e = Entry(1, Ref{Entry}(), Ref{Entry}(), record)

src/execute.jl

+6
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,13 @@ end
185185
function execute(buf, command::ReplaceCommand)::Union{VimMode,Nothing}
186186
inserted = 0
187187
for r1 in 1:command.r1
188+
move_right = is_line_max(buf)
188189
delete(buf, right(buf))
190+
if move_right
191+
let motion = right(buf)
192+
motion(buf)
193+
end
194+
end
189195
inserted += LE.edit_insert(buf, command.replacement)
190196
end
191197
if inserted > 0

src/operator.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ end
2323
function change(buf::IO, motion::Motion) #, motion_type :: MotionType)
2424
text = String(take!(copy(buf)))
2525
left = min(motion)
26-
right = min(max(motion), length(text))
27-
@debug "change operator" buf motion text left right
26+
right = min(max(motion), sizeof(text))
27+
@debug "change operator" buf motion text left right max(motion) length(text)
2828
yank(buf, motion)
2929
move(buf, motion) #, motion_type)
3030
LE.edit_splice!(buf, left => right)

test/command.jl

+15-9
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,20 @@ end
7070
@test run("|asdf", "dh") == testbuf("|asdf")
7171
@test run("asd|f", "X") == testbuf("as|f")
7272
@test run("asd|f", "x") == testbuf("as|d")
73-
73+
7474
@test run("|asdf", "s") == testbuf("|i|sdf")
7575
@test run("asd|f", "s") == testbuf("asd|i|")
7676
end
7777

7878
@testset "de" begin
79-
@test run("a|sdf", "de") == testbuf("a|")
79+
@test run("a|sdf qwerty", "de") == testbuf("a| qwerty")
80+
@test run("a|sdf", "de") == testbuf("|a")
8081
@test run("a|sdf abcd", "de") == testbuf("a| abcd")
8182
end
8283

8384
@testset "dw" begin
84-
@test run("a|", "dw") == testbuf("a|")
85+
@test run("|", "dw") == testbuf("|")
86+
@test run("|a", "dw") == testbuf("|")
8587
@test run("a|sdf abcd", "dw") == testbuf("a|abcd")
8688
end
8789
@testset "distinct behavior of dw and cw" begin
@@ -101,8 +103,8 @@ end
101103
@test run("a %%%|asdf b", "ciw") == testbuf("a %%%|i| b")
102104
@test run("a |asdf b", "ciw") == testbuf("a |i| b")
103105

104-
@test run("{3: three|}", "daw") == testbuf("3: thre|e")
105-
@test run("{3: thre|e}", "daw") == testbuf("3:|}")
106+
@test_skip run("{3: three|}", "daw") == testbuf("{3: thre|e")
107+
@test_skip run("{3: thre|e}", "daw") == testbuf("{3:|}")
106108
end
107109

108110
@testset "fFtT" begin
@@ -122,8 +124,8 @@ end
122124
end
123125

124126
@testset "D" begin
125-
@test run("aaaa bbbb |ccc ddd", "d\$") == testbuf("aaaa bbbb |")
126-
@test run("aaaa bbbb |ccc ddd", "D") == testbuf("aaaa bbbb |")
127+
@test run("aaaa bbbb |ccc ddd", "d\$") == testbuf("aaaa bbbb| ")
128+
@test run("aaaa bbbb |ccc ddd", "D") == testbuf("aaaa bbbb| ")
127129
@test run("aaaa bbbb |ccc ddd", "D") == run("aaaa bbbb |ccc ddd", "d\$")
128130
end
129131

@@ -163,7 +165,7 @@ end
163165
s = "\u2200 x \u2203 y"
164166
s = "∀ x ∃ y"
165167
@test run("|∀ x ∃ y", "w") == testbuf("∀ |x ∃ y")
166-
@test run("∀ x |∃ y", "w") == testbuf("∀ x |∃ y")
168+
@test run("∀ x |∃ y", "w") == testbuf("∀ x ∃ |y")
167169

168170

169171

@@ -188,7 +190,11 @@ end
188190
@test run("|abcde", "3rx") == testbuf("xx|xde")
189191
@test run("∀ x |∃ y", "rx") == testbuf("∀ x |x y")
190192

191-
@test run("∀ x ∃ |y", "rx") == testbuf("∀ x |∃ |x")
193+
t = run("∀ x ∃ |n|y", "rx")
194+
result = testbuf("∀ x ∃ |n|x")
195+
196+
@test_broken t == result
197+
192198
end
193199

194200
@testset "yank / put" begin

test/textobject.jl

+4
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ end
2424
# @test space(testbuf("this | space")) == (4, 5)
2525
# @test space(testbuf("this |space")) == (6, 6)
2626
end
27+
28+
@testset "inner/outer" begin
29+
30+
end

0 commit comments

Comments
 (0)