File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,12 @@ function examples.splitCursors(pattern)
50
50
return
51
51
end
52
52
local vs , ve = cursor :getVisual ()
53
+ if cursor :mode () == " V" or cursor :mode () == " S" then
54
+ vs [2 ] = 1
55
+ ve [2 ] = vim .fn .col ({ ve [1 ], " $" })
56
+ end
53
57
local last = vs
58
+ cursor :setMode (" v" )
54
59
for _ , match in ipairs (matches ) do
55
60
local lines = vim .split (match .text , " \n " , { plain = true })
56
61
local startPos = {
@@ -101,14 +106,13 @@ function examples.matchCursors(pattern)
101
106
})
102
107
local vs = cursor :getVisual ()
103
108
for _ , match in ipairs (matches ) do
104
- if # match .text > 0 then
105
- local newCursor = cursor :clone ()
106
- newCursor :setVisual (
107
- { vs [1 ], vs [2 ] + match .byteidx + # match .text - 1 },
108
- { vs [1 ], vs [2 ] + match .byteidx }
109
- )
110
- newCursor :setMode (" n" )
111
- end
109
+ local newCursor = cursor :clone ()
110
+ newCursor :setMode (" v" )
111
+ newCursor :setVisual (
112
+ { vs [1 ], vs [2 ] + match .byteidx },
113
+ { vs [1 ], vs [2 ] + match .byteidx
114
+ + math.max (0 , # match .text - 1 ) }
115
+ )
112
116
end
113
117
cursor :delete ()
114
118
end
You can’t perform that action at this time.
0 commit comments