Skip to content

Extend variants for tree-sitter textobject motions #3263

Closed
@the-mikedavis

Description

@the-mikedavis

Tree-sitter based textobject motions (for example ]f/[f) do not currently have different implementations between normal mode and select mode (v).

The behavior of these motions in select mode is worth some discussion. I see two options:

  1. Like ]p/[p or w/b in select mode, they should keep the anchor and move the head. This "extend" behavior is the normal behavior of motions in select mode. There is prior implementation-work for this behavior: Include treesitter objects in select mode #2802. (I'm looking at pulling this across the finish line now.)
  2. Like n/N, they should add new selections containing the next/previous textobject.

Option 2 is a bit unconventional (n/N is the only other that uses this behavior off the top of my head) but I think it would be more useful. Tree-sitter textobjects may not be contiguous in a file in the same way paragraphs are (by ]p/[p's definitions), so I think v]f would select other text between two function definitions I would not want. Even if this is not selected as the correct behavior, it might be good to adding separate commands that implement this behavior.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions