cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

`touch item sun` inside jsx selects whole tag instead of attribute

Open SimeonC opened this issue 2 years ago • 5 comments

Using this code <Button data-testid="Action Button" data-variant="bare">

CleanShot 2022-08-15 at 11 53 09

Say touch key air CleanShot 2022-08-15 at 11 53 41 Selects data-testid as expected.

Say touch value air CleanShot 2022-08-15 at 11 54 22 Also works as expected

Say touch item air CleanShot 2022-08-15 at 11 55 10 Selects the whole contents of the JSX not data-testid="Action Button"

SimeonC avatar Aug 15 '22 02:08 SimeonC

You can use "attribute" for that, although I can see how you'd expect "item" to work there, given we support it for key-value pairs elsewhere. Hmm. @AndreasArvidsson WDYT?

pokey avatar Aug 15 '22 05:08 pokey

Ahh, yes that works thanks. Didn't know about attribute

SimeonC avatar Aug 15 '22 06:08 SimeonC

Yeah it would probably be good if item worked here

AndreasArvidsson avatar Aug 15 '22 06:08 AndreasArvidsson

I definitely didn't expect item to select everything between <>

auscompgeek avatar Aug 15 '22 08:08 auscompgeek

Yeah agreed that's unintuitive. Fwiw the reason it does that is that "item" is just a text-based matcher that selects items in a comma-separated list surrounded by matching pairs. So in this case it saw the code as a single-element list between angle brackets 😄

pokey avatar Aug 15 '22 08:08 pokey

I'm unable to verify that this is fixed with Cursorless v0.26.740 and Parse tree v0.26.4.

Using the following source:

https://github.com/cursorless-dev/cursorless/blob/34d128fe33880991043cbeeeb3f23c689a721314/packages/cursorless-org/src/pages/cheatsheet.tsx#L19

highlight item (I'm using the keyboard interface):

highlight item

highlight attribute still works as expected:

highlight attribute

auscompgeek avatar Jul 09 '23 04:07 auscompgeek