zed icon indicating copy to clipboard operation
zed copied to clipboard

vim: Convert from visual mode to normal mode with a single click

Open WindSoilder opened this issue 1 year ago • 5 comments

Release Notes:

  • Fixed #4319

Here is a demo after the fix: https://github.com/zed-industries/zed/assets/22256154/a690f146-73c9-4b0e-8527-e4faf690cca2

Actually I'm not really sure should I submit my idea to discussion, since it's not a large change, and it's something like a bug fix. So I directly create a pr here.

WindSoilder avatar Jan 29 '24 12:01 WindSoilder

We require contributors to sign our Contributor License Agreement, and we don't have @WindSoilder on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

cla-bot[bot] avatar Jan 29 '24 12:01 cla-bot[bot]

@cla-bot check

WindSoilder avatar Jan 29 '24 12:01 WindSoilder

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Jan 29 '24 12:01 cla-bot[bot]

Hey! Thanks for this! With this change, does opt+click still work, to create multiple cursors?

mrnugget avatar Jan 29 '24 12:01 mrnugget

Thank you for a good question, I haven't thought about it.

After some testing, if I'm in visual mode, opt+click will go back to normal mode and create multiple cursors. If I'm in normal mode, opt+click will create multiple cursors as normal.

WindSoilder avatar Jan 29 '24 13:01 WindSoilder

@WindSoilder Thanks for the fix here!

I think we need to do this more carefully, as the current version breaks the visual block mode tests and opt-click in visual mode. If you want to pair with me on fixing this: https://calendly.com/conradirwin/pairing.

I think we should try only entering normal mode if there is exactly one selection and it is empty.

Some behaviors I'd like to work:

  • visual block mode onto an empty line (this is the test that's failing)
  • opt-click-and-drag to add another visual selection to an existing visual selection (currently this gets interrupted, I think because the local_selections_change fires on the click with an empty selection and stops my drag).
  • opt-click on another line in visual line mode to create a new visual line selection.

ConradIrwin avatar Jan 30 '24 03:01 ConradIrwin

@WindSoilder and I have a pairing session on Friday to get this over the line! Looking forward to it :D

ConradIrwin avatar Jan 31 '24 03:01 ConradIrwin

@ConradIrwin I tried the latest preview where this was merged and when some text is selected, clicking elsewhere doesn't activate normal mode like Vim would.

diocletiann avatar Feb 08 '24 14:02 diocletiann

@diocletiann strange, it seems to work for me... Are you clicking on the editor, or another part of the UI?

ConradIrwin avatar Feb 08 '24 17:02 ConradIrwin

@diocletiann strange, it seems to work for me... Are you clicking on the editor, or another part of the UI?

Never mind, it's working now. Maybe I tried it before updating Zed Preview.

diocletiann avatar Feb 08 '24 17:02 diocletiann