-
Notifications
You must be signed in to change notification settings - Fork 110
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
tide-references: make entire line clickable #278
base: master
Are you sure you want to change the base?
tide-references: make entire line clickable #278
Conversation
Note that the presentation doesn't change; only the symbol in question is highlighted, but you can now click anywhere in the line to jump to the reference 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.
I've also been annoyed at having to move to the identifier I searched for in order to be able to navigate to its occurrence. I pretty much always forget that it is not grep
and always first just hit enter on the line before remembering that I have to move to the specific occurrence. So I'm in favor of the general idea of making *tide-references*
less strict for navigation.
However, the proposed modification does not work well if the symbol that was searched for appears multiple times on the same line. I tried searching references to db
in a project that has return db.transaction("rw", db.packs, db.xmlfiles, () => {
. The behavior pre-PR is that I have to go to one of the hits and when I hit enter on it, then I'm taken to that specific hit. post-PR the new behavior is that no matter where I hit enter, I'm taken to the last hit on the line. It is confusing if a user has focused on one specific hit, to be taken to another hit and have to move again to get to the correct hit.
And the proposed modification messes up navigation in *tide-references*
. n
and p
are supposed to move from hit to hit, but after applying the PR they move from line to line.
Here's an idea, off the top of my head. I don't know how well it would work when it comes down to the nitty-gritty but maybe the tide-goto-reference
function could compute a column number to jump to by taking the column number at which point
is when the user hits enter, adjusted to take into account the line numbers that are added at the beginning of each line in the *tide-references*
buffer. This way, the user would land in a position that corresponds to where point
was when the user hit enter.
(Tangential note: we really should have formal tests for this in the test suite.)
@lddubeau I like your idea. Two questions: Should we collapse multiple hits into one line? Do you think it's all right for 'n' and 'p' to just move from line to line in that case? |
What has always annoyed me with I agree there's reasons for why things are like they currently are, like multiple hits/references on the same line. That said... If we are to change this to work like Right now If we are to change this behaviour to be more in line with how other "common" Emacs-functions work, it would really be great to have it work similarly at the core, not just at the appearance-level. |
We discussed about the UI change in the past. If somebody interested in spending time on this area, probably look at adding support for Xref. Emacs comes with a default UI and other frameworks could hook into xref and customize like https://github.com/brotzeit/helm-xref, https://github.com/alexmurray/ivy-xref |
@sandersn Regarding your second question, with what I have in mind The change I proposed in response to the initial PR would not include any cosmetic change: the The above was my initial "off the top of my head" idea. I can see arguments for some amendments to that idea. For instance, a case could be made that although @josteink I agree that I realize the proposal here does nothing with regards to addressing bindings to |
Agreed. And I think that should be fixed too.
Which is good.
Yeah. That's just me wishing. I don't strictly see it as a requirement, but if we could get it working while redoing this porting of the code, I just thought that would be nice, because then it would be even more in line with how grep, occur and similar work in Emacs. If it can't be done or nobody wants to do it, I'm not going to stall this PR over that, |
I ran into this annoyance too, and some more; and @lddubeau's idea seemed appealing so I implemented it. It doesn't change (defun tide-goto-reference-line ()
"Jump to reference location in the file."
(interactive)
(-when-let* ((bol (line-beginning-position))
(line (1+ (next-single-property-change bol 'face))) ; after the ":"
(col (max 0 (- (point) line)))
(ref (next-single-property-change bol 'tide-reference))
(ref* (get-text-property ref 'tide-reference)))
(tide-jump-to-filespan ref* nil t)
(goto-char (+ (line-beginning-position) col)))) Making this a proper PR shouldn't take too much: make it put text properties that are more reliable than relying on where the [I also ran into more related annoyces: a bug in |
Please do! 😃 |
Note that the presentation doesn't change; only the symbol in question is highlighted, but you can now click anywhere in the line to jump to the reference location.
I made this change for two reasons:
However, I think this change will benefit everybody by making the click target bigger.