Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add features to avoid accidentally editing text you can't see with an off-screen cursor #164

Closed
esthermations opened this issue May 29, 2021 · 9 comments
Labels
enhancement New feature or request question Further information is requested
Milestone

Comments

@esthermations
Copy link

I use multiple cursors in Dance quite a lot for little things like aligning stuff, adjusting indentation, bulk-renaming etc. I'm finding sometimes -- I'm not sure why -- that I end up with multiple cursors, all but one of which are off-screen. So I think I'm typing in one place, but in actual fact I'm doing horrible damage and writing very confusing things elsewhere in the file I'm editing.

I'd really like to have an option to bother me with a pop-up message when I'm about to edit lines that are off screen. You'll always hit this when using the % command or something but I don't do that too much -- probably about 90% of the time that I edit something with an off-screen cursor, it's an accident and I have no idea it's happening.

At the moment the only indication you have that you're editing something where you can't see is this teensy tiny text down the bottom-right that says how many selections you have:

image

I think making multiple cursors more obvious or just an option to avoid editing lines you can't see would be a handy addition.

In Vim people often set their modeline to a different colour in insert vs normal vs visual mode, maybe Dance could use colours for normal vs insert vs insert-with-many-cursors so you know when you're doing some funky stuff.

(NB: I tried setting dance.insertMode.lineHighlight but it only highlights one line, even when you have multiple cursors. I'm not sure if that's a bug or not, but it's definitely not helpful in this case.)

Thank you!

@71 71 added enhancement New feature or request question Further information is requested labels May 29, 2021
@71
Copy link
Owner

71 commented May 29, 2021

This is a good point. As you mention there are several ways we could make it more obvious that more than one selections are active. I'm not against adding a setting for styling selections based on whether there are multiple selections (e.g. having a different background color for the active line).

With that said, there are two problems with changing the color of the status bar in VS Code:

  1. It already changes in some situations (e.g. when debugging).
  2. More importantly, there is no "real" support for extensions to change the status bar color; extensions can programmatically change the value of the workbench.colorCustomizations.statusBar.background setting, but it incurs a slight lag and, more importantly, may update settings.json (which seems counterintuitive for a simple, temporary color change).

@esthermations
Copy link
Author

Ah, the status bar colour thing is a shame, that would've been a nice solution. Another option would be a pop-up message warning me about editing off-screen text, or maybe just an option to disallow cursors from going off-screen entirely (maybe by just removing cursors that go off-screen).

I'm not really sure. In Vim I don't think I ever accidentally edited text off screen, but in Kakoune/Dance you have cursors going all over the shop, which opens up a whole new world of mistakes you can make. Since editing text in programming is such a subconscious, flow-state thing it's really easy to just assume everything is working as expected. Sometimes multi-cursor editing can violate the principle of least astonishment, so I think effective communication through UI is quite important to mitigate that.

Thanks for the consideration, in any case. Dance is fantastic and I'm really happy I can get back to my Kakoune muscle memory in VS Code.

@Delapouite
Copy link
Contributor

Related issue on Kakoune side: mawww/kakoune#2727

@71
Copy link
Owner

71 commented May 30, 2021

There are many good ideas in this thread, thanks for linking.

Do note that if it ends up being added, it will only work for selections that are above or below the viewport, not the ones that are on the left or right of the viewport, since VS Code does not expose an API to know what columns are in the viewport.

@71
Copy link
Owner

71 commented May 30, 2021

I have a prototype that displays at the top and bottom of the screen if some selections are hidden; I'm not sure what colors I should pick, though. I went with editorWarning.{background,foreground} at first, but they're not particularly obvious.

image

Edit: Here it is with inputValidation.warningBackground and list.warningForeground:

image

@71 71 closed this as completed in 7d3dbb1 May 30, 2021
@71 71 added this to the 0.5 milestone May 30, 2021
@BeastyBlacksmith
Copy link

I know I am a bit late to the party, but in my color-scheme the colored bar is a little bit too much for me, is there a way to only have the text?

@71
Copy link
Owner

71 commented Jun 2, 2021

@BeastyBlacksmith Right now, no, but settings could be added for this.

@71
Copy link
Owner

71 commented Jun 2, 2021

86afe9b adds a setting for this.

"dance.modes": {
  "...": {
    "hiddenSelectionsIndicatorsDecoration": {
      "...": "...",
    },
  },
},

To specify a default that applies to all modes, use the empty "" mode.

@esthermations
Copy link
Author

FWIW for future reference, I think a big way I was accidentally getting multiple selections was by trying to use shift+N (vim key) to go to the previous search option, rather than alt+N (dance key).

Shift+N extends your selection to include the next search option, which also jumps your screen to it, so it's easy to miss that your selection just expanded when you do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants