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
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
SyntacticScopeTargetWhat
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
removalRangeto the upgraded targetThe core removal range will be the value passed in to
removalRangein constructor, otherwise content range.Other thoughts
Alternately we could add this implementation to
BaseTarget, so that things likeSyntacticScopeTargetwill get it, but not getLineTarget,TokenTarget,UntypedTarget(?) will override it, but let's start withSyntacticScopeTargetfor now