cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

Add new `anyOf` compound scope type

Open pokey opened this issue 3 years ago • 0 comments

Not sure if anyOf is the right name, but we should support a way to compose scope types like the following:

interface AnyOfScopeType {
    type: "anyOf";
    scopeTypes: ScopeType[]
}

Then we can construct a AnyOfScopeHandler that will behave the same as a hierarchical scope where each scope can be any of scopeTypes. So basically:

  • getScopesTouchingPosition: return smallest scopes of any of scopeTypes touching position
  • getScopesOverlappingRange: call getScopesOverlappingRange on all scopeTypes and then remove any scopes that are contained by another scope
  • getScopeRelativeToPosition: pick first scope of any of the scopeTypes, then skip it for offset > 1, etc
  • getIterationScopesTouchingPosition: not sure. maybe call this on all scopeTypes and use the smallest iteration scope?

Use cases

  • #1046
  • #1047
  • defining "name" as a union of "class name", "function name", etc
  • to define iteration scope of surrounding pair to be union of "inside" and "file"
  • users could map a custom scope type Talon side that constructs an anyOf scope type to enable them to construct their own unions of other scope types
  • we could maybe map a spoken form "<scope> or <scope>" to construct these on the fly, eg "take next funk or class"

Possible names

  • cascading
  • union
  • anyOf
  • oneOf
  • or

pokey avatar Oct 20 '22 13:10 pokey