Unable to Open Pas File when project file in another directory

Issue #64 on hold
Michael Honan created an issue

Receiving an error: Unable to open 'Unit1.pas': File not found (file:///d:/Repositories/MyApp/Projects/D:/Repositories/MyApp/Source/Folder1/Unit1.pas).

When double clicking on errors / warnings in the problems pane.

I'm guessing it's because our project files are in a different directory to the source files. Here's a representation of our source tree:

├───.vscode
├───Projects
│   ├───MyApp.dpr
│   └───MyApp.dproj
└───Source
│   ├───Folder1
│   │   └───Unit1.pas

The error still occurs regardless of what project is set.

I included the a quick project I reproduced the bug in. You can simply run it and see the bug when you try to double click the error in the error pane.

Comments (2)

  1. Christopher Wosinski repo owner

    Hi Michael, this is more a VSCode issue than an OmniPascal issue by now.

    The problem is in the task definition file tasks.json. There you see a problemMatcher definition. This part is responsible for parsing the compiler messages and turning them into hints, warnings and errors. The fileLocation property defines whether the compiler prints out absolute file paths or relative ones. Unfortunately the Delphi compiler prints both absolute and relative paths. The current problem matcher implementation in VSCode doesn't support mixed output, so you have to chose between the messages you want to be able to click on in order to move to their file locations. OmniPascal is generating the tasks.json expecting to see relative file locations more often. If this default setting doesn't fit your needs then you might want to adjust the tasks.json file.

    Just replace both occurences of

    "fileLocation": ["relative", "D:/Temp/OmniPascalBugProject/Projects"],

    with

    "fileLocation": ["absolute"],

    to change the problem matcher's behaviour. If you don't want to get your changes overwritten the next time you load the project in VSCode then open the workspace settings and set "omnipascal.createBuildScripts": false and reload VSCode afterwards.

    There is already a feature request for adjusting the compile script templates here: https://bitbucket.org/Wosi/omnipascalissues/issues/51/allow-modification-of-the-tempate-used-to As soon as this is implemented you will be able to define absolute file paths as default.

    But this only moves the problem from not supporting absolute file paths to not supporting relative file paths. That can only be solved when the VSCode problem matcher gets an autoDetect mode. You can vote for that feature here: https://github.com/Microsoft/vscode/issues/449

    I set this issue to ON HOLD until the feature is available in VSCode.

  2. Log in to comment