Unable to navigate to compilation errors outside of project's root folder

Issue #17 on hold
citi created an issue

When editing code that is shared between two projects, the .pas files are not located under the project's root folder. The search path to this code is specified using the "objectpascal.searchPath" setting. When an error is introduced in that part of the source code, VSCode is unable to locate the file as hitting F8 or F1 + ! will concatenate the absolute path of the project folder and the absolute path of the external file. As most of the code I am editing is part of this shared code base this issue is forcing me back to using Embarcadero's unstable IDE...

Comments (2)

  1. Christopher Wosinski repo owner

    This problem is related to VSCode's built in problem matcher in conjunction with the command line output of the Delphi compiler. You have a tasks.json file where the build command is defined. In that file you also define a problem matcher which creates hints, warnings and errors from the compiler's command line output. The problem matcher can be run in two different modes for file location handling: relative and absolute. If you are using the problem matcher as defined on blog.omnipascal.com then you will find this line in the problem matcher definition: "fileLocation": ["relative", "${workspaceRoot}"] If you change it to "fileLocation": ["absolute"] then all file locations from the command line output will be handled as absolute paths. So there won't be the wrong concatenation of paths anymore. Unfortunately this will break the proper creation of hints, warning and errors when the corresponding file name is reported relative to the project file where it belongs to. As you say most of your code doesn't belong to the project itself you will be more satisfied when using absolute file locations in the problem matcher. Read more about tasks.json and problem matchers here: https://code.visualstudio.com/docs/editor/tasks

    I'd like to provide a better answer that solves your problem at all but I can't as long VSCode's problem matcher doesn't support auto detection for file location as suggested here: https://github.com/Microsoft/vscode/issues/449#issuecomment-158912306

    P.S.: The "objectpascal.searchPath" setting is used for resolving symbols inside the editor only. There is no connection to the compilation tasks defined in the tasks.json.

  2. citi reporter

    Thank you. Let's hope the VSCode team implements the suggested "fileLocation": ["autoDetect"]. Keep up the good work!

  3. Log in to comment