Skip to content

Add action to add a type annotation #442

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

Open
alexhwoods opened this issue Jan 10, 2022 · 13 comments
Open

Add action to add a type annotation #442

alexhwoods opened this issue Jan 10, 2022 · 13 comments
Labels
enhancement New feature or request

Comments

@alexhwoods
Copy link
Contributor

alexhwoods commented Jan 10, 2022

What we want

We will make it so that the "clear" / "change" action, when applied to "type", if there is no existing type annotation, will insert a : and leave the cursor afterwords so that the user can add a type.

For example:

function foo() {
  return "hello" // cursor at end of this line
}

User says “change type”, results in

function foo(): <cursor-here> {
  return "hello"
}

Implementation

We will leverage #210 to make it so that target returned from "type" knows how to insert itself

@pokey pokey changed the title Cursorless not aware of return types to a function Add action to add a type annotation Jan 10, 2022
@pokey
Copy link
Member

pokey commented Jan 11, 2022

@AndreasArvidsson
Copy link
Member

I'm unsure if I like the idea of clear actually adding text.

@pokey
Copy link
Member

pokey commented Jan 12, 2022

I have slightly mixed feelings as well. But the capability described here seems useful. Any ideas for alternative ways to express this command?

@AndreasArvidsson
Copy link
Member

I agree that it's useful and I have had a need for something similar.

@pokey pokey added the enhancement New feature or request label Jan 12, 2022
@soheeyang
Copy link

I'm sorry for the late catch-up! I also think that the command would be useful, but using clear for this function might not be an optimal solution.

@pokey
Copy link
Member

pokey commented Jan 15, 2022

So do we add a new "add" action then? "Set"?

@soheeyang
Copy link

Would there be more cases to add something other than type? (Would the action be more generalized?)
Also, for the languages that do not have the type annotation, would the command be deactivated?

@AndreasArvidsson
Copy link
Member

When the action is called change it makes perfect sense. As a clear command I'm a bit ambivalent. Also adding a new action for this very niche case is probably unnecessary.

@soheeyang
Copy link

My opinion is the same as Andreas's.

@pokey
Copy link
Member

pokey commented Jan 15, 2022

But the action is called "change" today

@AndreasArvidsson
Copy link
Member

The default spoken form is. The action is called clearAndSetSelection

@pokey
Copy link
Member

pokey commented Jan 15, 2022

Yes maybe we were a bit too explicit there 😅

@AndreasArvidsson
Copy link
Member

Yes if the action is going to be change on even add the action name is definitely incorrect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants