Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch targets to object-oriented #210

Closed
pokey opened this issue Aug 10, 2021 · 5 comments · Fixed by #672
Closed

Switch targets to object-oriented #210

pokey opened this issue Aug 10, 2021 · 5 comments · Fixed by #672
Assignees
Labels
code quality Improvements to code quality
Milestone

Comments

@pokey
Copy link
Member

pokey commented Aug 10, 2021

The problem

As we move towards fully compositional cursorless modifier pipelines (#69), each cursorless target needs to have enough information so that subsequent pipeline steps can do their job. In addition, we have found that oftentimes different actions need to repeat the the same code to operate on a given type of target. For example, the "chuck", "move" and "carve" commands all need to know how to remove a given target. We'd like to bake more intelligence into the targets themselves.

In addition, once we have #46, we want to have rich targets that can refer to more than just locations in a document. Having smart targets will enable many advanced use cases. See What's next for more.

The solution

Target will become object-oriented, with the following methods

  • getContentSelection (used for selection, get text, highlight for reference)
  • getRemovalDecorationRange
  • constructChangeEdit (takes text)
  • constructInsertionEdit (takes text and returns edit that has range as a selection, so that paste can use empty string then set cursor to active before pasting)
  • constructRemovalEdit

The target will also have the following, but somehow hide it before action sees it because it shouldn't be used there. It's mostly for downstream pipeline stages, eg "after":

Other stuff to think about

Positional modifier is just a pipeline stage

Need to have proper "insert" command and then can distinguish between "insert after" vs "change after" (changes delimiter)

@AndreasArvidsson
Copy link
Member

AndreasArvidsson commented Aug 15, 2021

  • Remove inside/outside as proper modifiers
  • Add start of/end of as proper modifiers
  • Create a draft target type used in the pipeline. Gets converted into a function only finalized target at the end.
    • contentRange
    • deletionRange?
    • deletionDecorationRange?
    • leadingDelimiterRange?
    • trailingDelimiterRange?

@pokey
Copy link
Member Author

pokey commented Aug 16, 2021

I think we prob potentially want edit constructors instead of ranges, eg for camel-case, no?

1 similar comment
@pokey
Copy link
Member Author

pokey commented Aug 16, 2021

I think we prob potentially want edit constructors instead of ranges, eg for camel-case, no?

@pokey
Copy link
Member Author

pokey commented Aug 16, 2021

I think we prob want constructInsertionEdit to take a list of texts, so that we can handle #184

@AndreasArvidsson
Copy link
Member

We can do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Improvements to code quality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants