Skip to content

Update scope type modifier to expand on both ends #484

@AndreasArvidsson

Description

@AndreasArvidsson

Right now you can take lines paragraphs and soon non whitespace sequences that expands from both anchor and active of the selection. Currently containing scopes only use start off the selection.

I want both of these to have the same result. (air and bat are in different functions)
take funk air past bat
take air past bat take funk

I was thinking that we could implement this first thing in the selection/scope modifier by basically calling the specific implementation twice, once for both ends. To day we pass the entire selection to the specific modifier(line, funk, ...). What if we pass in a single position instead?

const startSelection = getSelectionForScope(selection.start, "function"); // function is of course a variable
if (selection.isEmpty() 
  || getNodeAtLocation(selection.start).id === getNodeAtLocation(selection.end).id) {
    return startSelection;
}
const endSelection = getSelectionForScope(selection.end, "function");
return  getSelectionFromPositions(startSelection.start, endSelection.end);

edit (@pokey)

Let's implement this one in a new ContainingScope stage that all containing scopes share. The algorithm should be as described in #629 (comment). The initial implementation will be folded into #629

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions