Skip to content

Automatically try to remove scopes as if they're token, line, block, file if they have no removal behaviour #855

Description

@pokey

Most of our tree-sitter scopes don't remove newlines, and some of them don't remove spaces. We'd like a way to make them all automatically remove the appropriate whitespace

I would argue that we should detect if something stops at a line boundary and use newline delimiter if so.

Implementation

Where

Let's start by putting it on SyntacticScopeTarget

What

If target has leading or trailing range, we use today's behaviour.

Otherwise, we see if the "core removal range" corresponds to the entire file, then falling back to block, then line, then token. If it corresponds to one of these, we forward calls to removalRange to the upgraded target

The core removal range will be the value passed in to removalRange in constructor, otherwise content range.

Other thoughts

Alternately we could add this implementation to BaseTarget, so that things like SyntacticScopeTarget will get it, but not get LineTarget, TokenTarget, UntypedTarget (?) will override it, but let's start with SyntacticScopeTarget for now

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions