-
Notifications
You must be signed in to change notification settings - Fork 203
Added back support for Hyperclick #1265
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
Conversation
Hyperclick support dissapeared after a refactor. Added the old code back, and updated it to work with the new API, as used in `go-to-definition`. Included support for selecting between multiple definitions.
Right, I saw some state related to that in the jump-to-definition code. This should probably be unified somehow, and I can see what I can do :). Thanks for the feedback! |
- Didn't cooperate with go-to-declaration, so return from declaration didn't work - Actually used the position from the cursor, not the point of the click
@splodingsocks Thank you again for the feedback! I fixed the issue with returning to definition with |
Nice!! |
@guncha Am I missing something in this pull request? I'm happy to clean it up if anything's missing. |
this should fix #1234 as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but needs a few more changes!
|
||
export function handleDefinitionResult(result: protocol.DefinitionResponse, | ||
location: FileLocationQuery): void { | ||
if (result.body!.length > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional body on the protocol.DefinitionResponse
is there for a reason - Typescript might not return a definition in which case this will blow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I just copied it, but then it was in a promise, so I guess we can argue the exception was handled :).
Fixed it now.
lib/main/atom/hyperclickProvider.ts
Outdated
wordRegExp: /([A-Za-z0-9_])+|['"`](\\.|[^'"`\\\\])*['"`]/g, | ||
getSuggestionForWord(editor: AtomCore.IEditor, text: string, range: TextBuffer.IRange) { | ||
const TS_GRAMMARS = ["source.ts", "source.tsx"]; | ||
if (TS_GRAMMARS.indexOf(editor.getGrammar().scopeName) === -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use isTypescriptGrammar
helper from typescriptEditorPane.ts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I extracted it and put it in utils.
Solid PR! 👍 I could have sworn I wrote a comment about using the scopes from the Typescript grammar to narrow down the locations where Hyperclick is effective. Basically, when you return from the function, the That's something that would take this from 95% to 100%, but it can be a part of a separate PR. I'll release this so people can start using it. |
Great suggestion 😊 I started looking into the scopes, and have something basic running. I'll try to come up with a list of what's not hyperclickable, and I can push it as a separate pull request. I think I need to add From the top of my head:
Thanks a lot! |
Sounds about right. You can always add it to the |
Hyperclick support dissapeared after a refactor.
Added the old code back, and updated it to work with the new API, as
used in
go-to-definition
. Included support for selecting betweenmultiple definitions.
Should fix #448 and #1253