@@ -1774,6 +1774,7 @@ local function clearCursorContext()
1774
1774
state .errors = {}
1775
1775
state .jumpIdx = 0
1776
1776
state .yankedWhileDisabled = false
1777
+ state .yankedWhileActive = false
1777
1778
unsetOptions ()
1778
1779
unsetHlsearch ()
1779
1780
state .yanked = false
@@ -2292,6 +2293,7 @@ function CursorManager:action(callback, opts)
2292
2293
end
2293
2294
2294
2295
if state .yanked then
2296
+ state .yankedWhileActive = true
2295
2297
state .yanked = false
2296
2298
state .cursors [# state .cursors + 1 ] = state .mainCursor
2297
2299
table.sort (state .cursors , compareCursorsPosition )
@@ -2310,6 +2312,25 @@ function CursorManager:action(callback, opts)
2310
2312
then
2311
2313
state .yankedWhileDisabled = true
2312
2314
end
2315
+ elseif not state .yankedWhileActive then
2316
+ --- @type mc.StateHistoryItem
2317
+ local item = state .stateHistory [historyItemId ()]
2318
+ if item then
2319
+ local oldCursors = tbl .shallow_copy (item .cursors )
2320
+ local newCursors = tbl .shallow_copy (state .cursors )
2321
+ newCursors [# newCursors + 1 ] = state .mainCursor
2322
+ oldCursors [# oldCursors + 1 ] = item .cursor
2323
+ table.sort (newCursors , compareCursorsPosition )
2324
+ table.sort (oldCursors , compareCursorsPosition )
2325
+ for i , oldCursor in ipairs (oldCursors ) do
2326
+ local newCursor = newCursors [i ]
2327
+ if not newCursor then
2328
+ break
2329
+ end
2330
+ newCursor ._register = oldCursor ._register
2331
+ end
2332
+ vim .fn .setreg (" " , state .mainCursor ._register )
2333
+ end
2313
2334
end
2314
2335
2315
2336
cursorContextUpdate (not opts .excludeMainCursor )
0 commit comments