orbitalquark / textadept

Textadept is a fast, minimalist, and remarkably extensible cross-platform text editor for programmers.
https://orbitalquark.github.io/textadept
MIT License
653 stars 39 forks source link

goto_error fails with wrong path #328

Closed snoopy closed 1 year ago

snoopy commented 1 year ago

Sometimes goto_error prepends the TA installation path to the filename. Some of this can be alleviated by changing sloppy to true in https://github.com/orbitalquark/textadept/blob/c5880ec0c0cd17fcbfefc0fc7b109b4f436167cc/modules/textadept/run.lua#L444

Prior to that I'm calling clang-tidy for the current project and file like this:

textadept.run.run_project(nil, 'clang-tidy-command-invocation')

The command runs fine but when calling goto_error the resulting path sometimes ends up looks something like this: <TA-installation-path>\\<path-to-file>. I observed this on windows and linux.

orbitalquark commented 1 year ago

This is tricky because relative paths are often not printed with context. When encountering a relative path, Textadept does not know the root the path is relative to. (It often changes depending on the compile/run/build/test command being run.) That's why sloppy is being used, but as you've pointed out, it's not perfect. The fallback is the current working directory.

If you're sticking to one project, you can try running lfs.chdir(io.get_project_root()) to change the current working directory from _HOME to your project's root. That might help.

I'm not sure how else to improve this, but am open to ideas.

snoopy commented 1 year ago

Thanks, I'll look into using lfs.chdir(io.get_project_root()).