cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

Automatically detect delimiter for scope type targets

Open pokey opened this issue 2 years ago • 9 comments

I tried "pour element", and found it quite bothersome that it tried to insert a space instead of making a new line, like the old behaviour. I would argue that we should detect if something stops at a line boundary and use newline delimiter if so.

@AndreasArvidsson I believe you had some reason why we shouldn't do that but I can't remember what it was

pokey avatar Jul 11 '22 15:07 pokey

Do you want this behavior only for pour or also for bring? Should some scopes types be omitted? Because now when we have textual item scope "pour item" should definitely not insert a line just because it is the last token on the line.

AndreasArvidsson avatar Jul 11 '22 15:07 AndreasArvidsson

If something is the last token on the line it will not count as a line. It needs to start and end on line boundary

It will also only be if the scope type has no explicit delimiter set, so wouldn't affect item for that reason as well

pokey avatar Jul 11 '22 15:07 pokey

I guess for scope types that have no specific insertion delimiter this could work. How will you handle multiline targets? Check both first and last line? Leading and trailing white space will be omitted from the line calculation?

AndreasArvidsson avatar Jul 11 '22 15:07 AndreasArvidsson

Yep!

pokey avatar Jul 11 '22 16:07 pokey

I think we can also consider detecting we're a block and set it to \n\n, though not quite as critical as the newline one. That one gets me because it feels like a regression in situations like this one

pokey avatar Jul 11 '22 16:07 pokey

This one is also super annoying for "section" in markdown, eg "clone up section"

pokey avatar Jul 18 '22 14:07 pokey

The current solution for these is of course that they have the wrong delimiter. Section should definitely not insert or remove as a token.

AndreasArvidsson avatar Jul 19 '22 15:07 AndreasArvidsson

Yeah maybe for now let's just add them to that switch statement, but I do worry it's going to start feeling like a game of whack-a-mole

pokey avatar Jul 19 '22 21:07 pokey

Agreed. We should definitely have a proper look at an alternative solution. But just for now I think we should just add them to the delimiter list.

AndreasArvidsson avatar Jul 19 '22 21:07 AndreasArvidsson