You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix bug where clipboard would be polluted when showing Services menu
Previously, whenever the user selects some text in MacVim, and then
bring up the Services menu (either by right-clicking on the selection,
or go to MacVim -> Services), MacVim will copy the selected text to the
system clipboard, which is quite an unexpected behavior. Fix that here.
Part of the issue is that Vim has built-in ways to convert the selected
range to a single copyable text, while managing complexities of dealing
with blockwise/linewise modes. Previous implementation in MacVim was
lazy in that it just invoked those code, but the side effect was that it
would also copy the text to the system clipboard and pollute Vim's star
register as well. This was quite undesirable because the user has not
done anything other than opening a menu and wouldn't have expected the
system clipboard or the Vim registers to have changed.
In this fix, we unfortunately had to do a little bit more copy-pasting
to extract the useful bits so we can copy the text to a register (but
not system clipboard), invoke the code to convert the register to
clipboard-happy text, restore the register, and then move on. A little
annoying but better than having the unintuitive / annoying behaveior
from before, and this way we don't have to do too much intrusive
refactoring of upstream Vim code as well.
// Step 4: Clean up the yank register, and restore it back.
1431
+
set_y_current(target_reg); // should not be necessary as it's done in do_pending_operator above (since regname was set to 0), but just to be safe and verbose in intention.
1432
+
free_yank_all();
1433
+
*target_reg = backup_reg;
1434
+
1435
+
// Step 5: Restore all the loose states that were modified during yank.
1436
+
// Note: These were copied from clip_get_selection() in clipboard.c
1437
+
set_y_previous(old_y_previous);
1438
+
set_y_current(old_y_current);
1439
+
curwin->w_cursor = old_cursor;
1440
+
changed_cline_bef_curs(); // need to update w_virtcol et al
1441
+
curwin->w_curswant = old_curswant;
1442
+
curwin->w_set_curswant = old_set_curswant;
1443
+
curbuf->b_op_start = old_op_start;
1444
+
curbuf->b_op_end = old_op_end;
1445
+
VIsual = old_visual;
1446
+
VIsual_mode = old_visual_mode;
1447
+
1448
+
unblock_autocmds();
1449
+
1450
+
return convert_result;
1451
+
}
1452
+
1453
+
/// Extract the currently selected text (in visual mode) and send that to the
0 commit comments