-
Notifications
You must be signed in to change notification settings - Fork 8
feat: hold down ctrl/meta to go-to-def on clicks #42
Conversation
Codecov Report
@@ Coverage Diff @@
## master #42 +/- ##
==========================================
- Coverage 65.24% 64.86% -0.39%
==========================================
Files 15 15
Lines 587 609 +22
Branches 155 157 +2
==========================================
+ Hits 383 395 +12
- Misses 204 214 +10
Continue to review full report at Codecov.
|
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.
Did you know about MouseEvent.metaKey
or MouseEvent.ctrlKey
? metaKey
is true if command or the windows key was held down and ctrlKey
is true if control was held down during the mouse event. See how we use these to determine whether to open a new tab or not when you click J2D before the jump url is finished loading.
The changes in positions.ts
that add keyboard events and track currently hovered tokens seem like they could cause race conditions and are probably unnecessary with these properties :)
@@ -34,7 +34,7 @@ describe('Hoverifier', () => { | |||
scheduler.run(({ cold, expectObservable }) => { | |||
const hoverifier = createHoverifier({ | |||
closeButtonClicks: new Observable<MouseEvent>(), | |||
goToDefinitionClicks: new Observable<MouseEvent>(), | |||
goToDefinitionClicks: new Subject<MouseEvent>(), |
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.
Why this change?
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.
To enable this (can't next
an observable): https://github.com/sourcegraph/codeintellify/pull/42/files#diff-8a128e9e8a5a8bb9767f5f5392391217R434
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.
👍 btw you can just pass the subject in to subscribe instead of wrapping it in an arrow func and calling next on it
Plus if you use the |
So I DO use The addition of |
And yes I absolutely need to add tests! |
By this do you mean underlining the token to look like a link? |
Yep. Otherwise, nothing gets re-rendered on key presses. This might be an acceptable change given how much simpler the code would be, but it would be a bit weird to give the user no indication that their click has a different meaning. |
Sorry, didn't read the code all that closely once I saw the changes in I'd like to get rid of the usage of I wonder if we could do something like take the latest |
The colors clash right now. I'd like to change the light theme link to be #329AF0 or "Dodger Blue" from our style guide. Additionally, if the cmd/ctrl key is pressed and hovered over a link that will go-to-def, I think the tool tip should disappear since it crowds the UI and provides the same features. |
It only adds the go to def support, not the other features. For that reason I think it should stay around. Also, the tooltip is there for the information it provides as well. The tooltips in vscode stay around when you hold down cmd. |
Can we change the context of the tool tip to show the def like vscode does? If we could do this, I think it makes sense to remove the other options from the tool tip as you wouldn't have the cmd key pressed if it goes to def only to do something else. I think they're two distinct interactions that might be worth separating. |
So vscode goes from showing a little bit of information to more information when you hold it down. We actually just show all the information we have about the token no matter what. I think this is better in our use case since the main goal is to understand code rather than write code. So in other words, if the language server returns the definition, we show it already. |
I only took a brief look on this PR but I would not want to merge it in the current state. I can take a closer look once I’m back. Initial thoughts:
|
Video of how this works in dev: https://cl.ly/2k1n470y083b
My remaining concerns:
The action of pressing cmd/ctrl now causes any currently displayed hover to disappear (but you can move off of the symbol, and then back on to bring it back). This can probably be cleaned up.
My additions to position.ts seem a bit dangerous (adding global
hoverTarget
andhoverCodeView
vars, in particular). Any thoughts on how to improve this? https://github.com/sourcegraph/codeintellify/compare/cmdj2d?expand=1#diff-baad18ed00346ed65d8f93a0f6579b20R33Get @francisschmaltz's eyes on styling (see https://github.com/sourcegraph/sourcegraph/pull/12850)