Automatically try to remove scopes as if they're token, line, block, file if they have no removal behaviour
See original GitHub issueI 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.
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
Issue Analytics
- State:
- Created a year ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
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.
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