vscode-open-file-from-path
vscode-open-file-from-path copied to clipboard
Can't navigate to paths with a :lineNumber suffix?
I'm trying to match the paths in this output:
goroutine profile: total 176
44 @ 0x62926b 0x629313 0x63b29c 0x63aed9 0x678f45 0xc05ad3 0x658bf1
# 0x63aed8 sync.runtime_Semacquire+0x38 /usr/lib/golang/src/runtime/sema.go:56
# 0x678f44 sync.(*WaitGroup).Wait+0xb4 /usr/lib/golang/src/sync/waitgroup.go:130
using a custom regex: (?<=(\s|^))\/[^\s]+
It looks like my regex is doing what I expect: https://regexr.com/48jnn
But I get the error Open file from path: Current cursor position is not valid, check the 'open-file-from-path.regExp' option to configure your RegExp match when using alt+d with the cursor inside one of those paths.
Hi @vith! Thanks for the feedback. The error you see means that the plugin cannot find the string in which it should use the regex to get the final file path; so i think we are a step behind searching for a file. Are those strings in the editor when you try to run the command with alt+d? Thank you!
They were in an editor buffer and my cursor was in the middle of one of the paths. I believe it was in an unsaved buffer but today I can't reproduce that error.
Now I get Open file from path: Warning, no matches were found. in a saved buffer, and nothing happens at all in an unsaved (untitled) buffer.
Ok now you maybe see this error because of the :lineNumber suffix. If you try to remove it and test the command again does it work? Thanks!
Nope, same thing with the :130 suffix removed: Open file from path: Warning, no matches were found.
Hello @vith, what is the value of the open-file-from-path.startingPath setting in your workspace? Remember that this setting is used to define the root of the project; are you trying to open a path outside of the root of your project?
It's /, which seems to be the default. But yes, /usr/lib/golang/src/runtime/sema.go:56 is an absolute path which is outside my ${workspaceRoot}. But absolute paths inside the ${workspaceRoot} didn't work either I believe. Are only relative paths supported?
Hello @vith, i just tried to open a file form this path: "include /views/includes/home-content.pug" and it's working for me. So can you try to set an absolute path pointing into the root of your project and see if it works? Thanks!
With open-file-from-path.startingPath set to /home/vith/test/, pressing alt+d on /home/vith/test/b.txt does nothing.
Not sure if that's what you meant for me to try. I think we may have some confusion between us about what kind of absolute paths are the problem. I'm talking about absolute filesystem paths, not the path part of a url. / refers to the root of the filesystem (on unixes). I should have mentioned I'm trying to use this on Linux, maybe you're on Windows?
To clarify, /home/vith/test/ was also the ${workspaceRoot} in the above test.