positron icon indicating copy to clipboard operation
positron copied to clipboard

Ctrl+click to go to function definition doesn't work if a comment contains the name of the function

Open etiennebacher opened this issue 1 year ago • 2 comments

System details:

Positron and OS details:

Positron Version: 2024.09.0 build 77 Code - OSS Version: 1.93.0 Commit: 9b6f7c066546a4c7f104368fc769fb3768b08bfd Date: 2024-09-23T02:37:45.666Z Electron: 30.4.0 Chromium: 124.0.6367.243 Node.js: 20.15.1 V8: 12.4.254.20-electron.0 OS: Linux x64 6.8.0-45-generic

Interpreter details:

R 4.4.1

Describe the issue:

In some cases, holding Ctrl and clicking on the name of a function doesn't go to the function definition, for instance if a comment has the same name as the function. In the example below, the cursor is moved to the comment instead of the function definition. This only occurs if the comment has 4 dashes or more (maybe because it's recognized as a section?):

my_function <- function() 1

# my_function ----

my_function(1)

Steps to reproduce the issue:

  1. Put this code in a file:
my_function <- function() 1

# my_function ----

my_function(1)
  1. Ctrl+click on my_function(1)

Expected or desired behavior:

Cursor should go to the function definition on the first line.

Were there any error messages in the UI, Output panel, or Developer Tools console?

No

etiennebacher avatar Oct 03 '24 09:10 etiennebacher

Thanks for flagging this! We appreciate your help improving Positron and we’ll address it when we’re working on the next release; keep an eye on this issue for updates 🚀. Thanks again for your help!

timtmok avatar Oct 04 '24 15:10 timtmok

Note that it seems to break only when ---- has been added to the comment. When it's just the function name, the navigation works.

timtmok avatar Oct 04 '24 15:10 timtmok

This bugs me too. I suspect it's somehow caused by markdown headings getting higher priority in symbol lookup than function names.

Image

hadley avatar Jan 27 '25 16:01 hadley

Verified Fixed

Positron Version(s) : 2025.08.0-126 OS Version(s) : MacOS

Test scenario(s)

Confirmed that Ctrl+Click on a function name now correctly navigates to the function definition, even when a section comment (e.g., # my_function ----) with the same name is present. Previously, the editor incorrectly prioritized the section heading. Marking the issue as resolved.

Link(s) to test cases run or created:

n/a

midleman avatar Aug 01 '25 15:08 midleman