question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Goto Declaration Unexpected Behavior for labels with hyphens

See original GitHub issue

PyCharm 2022.2.3 (Professional Edition) Build #PY-222.4345.23, built on October 10, 2022

Pop!_OS 22.04 LTS

TeXiFy IDEA 0.7.23

What I did (steps to reproduce)

  • Create a section with a label that has a hyphen in it
  • Later, create a reference back to that section.
  • Place the cursor to the left of the hyphen Goto Declaration (ctrl+b or ctrl+click)
  • Observe “No usages found” message (incorrect)
  • Place cursor to right of the hyphen and attempt Goto Declaration again
  • Observe Expected Behavior

Minimal example to reproduce the problem

Inconsistent/Incorrect Behavior

\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
	\section{Foo}\label{sec:foo-bar}
		Foo Bar~\ref{sec:foo-bar}
\end{document}

Consistent/Correct Behavior

\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
	\section{Foo}\label{sec:foobar}
		Foo Bar~\ref{sec:foobar}
\end{document}

Expected behavior

Goto Declaration will work consistently on both \ref{sec:foo-bar} and \ref{sec:foobar}

Actual behavior

Please refer back to steps to reproduce for more info.

When attempting a ctrl+click, one may notice that when hovering to the left of a hyphen, the blue underline does not extend across the whole reference. Moving the mouse to the right of the hyphen works as expected.

Notes

Adding more hyphens does not exacerbate the issue, only the first one suffers splitting.

Removing the : does not have any effect.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jojo2357commented, Oct 27, 2022

Sorry, not trying to rush you or anything, just gathering information since I wasn’t sure if it would help or not

0reactions
PHPiratescommented, Oct 27, 2022

Yes yes it’s all the same issue, I know what the problem is, we made hyphens a separate lexer token to enable folding them, but reference resolving works on the leaf psi element at the caret, so that should be one element and not be split up. Should probably just not have separate hyphen lexer token in required arguments, but that’s no fun in the lexer. Unfortunately I think doing this at parser level will not work, but we’ll see.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected behavior with hyphenated boolean options #879
The idea is that when someone specifies --no-foo in their CLI, they probably want a variable foo = false rather than a variable...
Read more >
Variable declaration after goto Label - Stack Overflow
I heard that one cannot create variables inside the case statements of switch. Since JUMP is inside the same scope (the scope of...
Read more >
Don't Use The Placeholder Attribute - Smashing Magazine
The placeholder attribute contains a surprising amount of issues that prevent it from delivering on what it promises. Let's clarify why you ...
Read more >
python code to change dash values to degree minute second
Solved: I'm a novice in programming and would appreciate if somebody can provide me with a Python code that can convert the values...
Read more >
Clang Language Extensions — Clang 16.0.0git documentation
Since it has undefined behavior, it is a statement that it is never reached and the optimizer can take advantage of this to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found