@@ -236,6 +236,11 @@ local function addCursor(ctx, motion, opts)
236
236
local startCol = vs [2 ] + colDiff
237
237
local endRow = ve [1 ] + rowDiff
238
238
local endCol = ve [2 ] + colDiff
239
+ local lastLine = vim .fn .line (" $" )
240
+ if endRow > lastLine then
241
+ endRow = lastLine
242
+ endCol = vim .fn .col ({lastLine , " $" })
243
+ end
239
244
if oldMode == " V" or oldMode == " S" then
240
245
startCol = vs [2 ]
241
246
endCol = ve [2 ]
@@ -571,17 +576,15 @@ local function matchAddCursor(direction, add)
571
576
searchWord = true
572
577
mainCursor :feedkeys (' "_yiw' )
573
578
end
574
- elseif vim .o .selection == " exclusive" then
575
- local vs , ve = mainCursor :getVisual ()
576
- if vs [1 ] < ve [1 ] and ve [2 ] == 1 then
577
- mainCursor :feedkeys (TERM_CODES .BS )
578
- end
579
579
end
580
580
addCursor (ctx , function (cursor )
581
581
local regex
582
582
local hasSelection = cursor :hasSelection ()
583
583
if hasSelection then
584
584
regex = " \\ C\\ V" .. escapeRegex (table.concat (cursor :getVisualLines (), " \n " ))
585
+ if vim .o .selection == " exclusive" then
586
+ regex = regex .. " \\ v.*\\ n"
587
+ end
585
588
if cursor :mode () == " V" or cursor :mode () == " S" then
586
589
cursor :feedkeys (cursor :atVisualStart () and " 0" or " o0" )
587
590
elseif not cursor :atVisualStart () then
0 commit comments