cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.15k stars 81 forks source link

Slice fails sometimes if using tabs. #1586

Open Emberstorm-John opened 1 year ago

Emberstorm-John commented 1 year ago

Command used: Take made past play rangle take slice yellow cross rangle

Behaviour: image

Expected Behaviour: image

Example code:

progressionDebug += "\n<indent=15%>Maps visited: "                  + "<indent=75%>" + mapsVisited                  + "</indent>";
        progressionDebug += "\n<indent=15%>Places visited total: "          + "<indent=75%>" + poisVisitedTotal             + "</indent>";
        progressionDebug += "\n<indent=15%>Misteries solved total: "        + "<indent=75%>" + poisSolvedTotal              + "</indent>";

        progressionDebug += "\n";
        progressionDebug += "\n<indent=15%>Villagers helped: "              + "<indent=75%>" + customersSolved              + "</indent>";
        progressionDebug += "\n<indent=15%>Trades made: "                   + "<indent=75%>" + tradesMade                   + "</indent>";

        progressionDebug += "\n<indent=15%>Deco built total: "              + "<indent=75%>" + bbsPlacedTotal               + "</indent>";
        progressionDebug += "\n<indent=15%>Deco removed: "                  + "<indent=75%>" + bbsRemoved                   + "</indent>";
pokey commented 1 year ago

This is almost certainly due to the fact that we're counting characters, rather than using display characters. Not sure if there's a way to use the latter, but that would solve this issue. wdyt @AndreasArvidsson?

AndreasArvidsson commented 1 year ago

I agree, but there is no way to do that to my knowledge.

pokey commented 1 year ago

I think it's probably doable. I believe there is a setting which will tell us the tab width, and then we can try to reproduce VSCode's tab display logic. It feels a bit dicey tho tbh, and things get even more confusing with grapheme clusters (see #1264), which are multiple javascript characters but show as a single display char. VSCode's logic for determining display columns is gnarly, so I'd be a bit nervous to try to reproduce it. We could try to handle the simple tab case, then leverage #1264 once we have that to make it even fancier. Prob not too bad

@Emberstorm-John you mentioned on slack you usually do this sort of thing by mouse and keyboard. Curious how you do that

Emberstorm-John commented 1 year ago

You can click top left corner of the rectangle and then click the bottom right with shift+alt+click. That is how I got the expected results screenshot.