-
Notifications
You must be signed in to change notification settings - Fork 202
add return-to-declaration functionality on the tsserver branch #1192
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
@@ -2,6 +2,15 @@ import {commands} from "./registry" | |||
import {commandForTypeScript, getFilePathPosition} from "../utils" | |||
import {simpleSelectionView} from "../views/simpleSelectionView" | |||
|
|||
const prevCursorPositions:any[] = []; |
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.
Missing the type annotation here. Once you add it, you'll discover a type mismatch between what getFilePathPosition
returns and what open
expects.
@@ -12,6 +21,8 @@ commands.set("typescript:go-to-declaration", deps => { | |||
const client = await deps.getClient(location.file) | |||
const result = await client.executeDefinition(location) | |||
|
|||
prevCursorPositions.push(location); |
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.
It's possible that the user executes this command, gets multiple results, but presses escape and doesn't open any of them. We don't want to record the previous position in that case - only if they make the jump.
open({ | ||
file: position.file, | ||
start: { line: position.line, offset: position.offset } | ||
}); |
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 new object you're creating here has the exact same shape as position
local, so there's no need for that. You could pass it directly, though you'll see that it's not what open
expects.
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.
Not completely sure what you mean here. position doesn't have a start
attribute, it looks like:
{
file: string,
line: number,
offset: number
}
Open expect the line
and offset
to be children of start
, which is why I wrote it out like that. Are you saying to just change the definition of open
to correspond with the position
argument?
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.
Oh, gotcha, I didn't see the start
bit. Carry on 😆
added those suggested fixes. let me know if you see anything else. |
Just thinking about this... |
Thanks @deanproxy 👍 |
[ ] All compiled assets are included (atom packages are git tags and hence the built files need to be a part of the source control)