在 VSCode 中未使用 OmniPascal 指定文件夹

Ordner nicht angegeben with OmniPascal in VSCode

人们在 Visual Studio 中打开文件时出现错误 OmniPascal:

Ordner nicht angegeben

转换为:

Folder not specified

确保用户 settings.json 中的路径已设置的第一个想法:

树皮当然是错误的:

settings.json:

// Place your settings in this file to overwrite the default settings
{
    "objectpascal.delphiInstallationPath": "D:\Programs\Embarcadero\Studio\14.0",
    "objectpascal.searchPath": "D:\Delphi Components"
}

错误肯定来自 OmniPascal,因为它是一个字符串

bin\win\OmniPascalServer.exe

我不是唯一得到这个的人

Anonymous 有同样的问题:

When I open a .pas file by right clicking on the file in windows explorer, the file opens correctly, but then a messagedialog appears with "Ordner nicht angegeben"' and an OK button.

有调试代码的方法吗?

我可以在 VSCode 里面看到 工作区根路径 :

有一个变量

objectPascalServiceClient.js

var config = vscode.workspace.getConfiguration('objectpascal');  
var delphiSDK = config.get('delphiInstallationPath', '');
var searchPath = config.get('searchPath', '');                                                                
var workspacePath = vscode.workspace.rootPath;
if (typeof delphiSDK == 'undefined')
   delphiSDK = "";
if (typeof searchPath == 'undefined')
   searchPath = "";                            

if (isWin) {
    childProcess = cp.spawn(path.join(__dirname, 'bin/win/OmniPascalServer.exe'), [workspacePath, delphiSDK, searchPath]);
                    }

有源代码吗?

OmniPascal 似乎是废弃软件。有没有人可以尝试准确破译的源代码?

真正的 问题是如何摆脱使用 window 阻止的模态对话框。

It looks like OmniPascal is abandonware

不,即使在过去几个月内没有新的 public 版本,它也绝对不是废弃软件。 OmniPascal 仍在积极开发中。

The real question is how to get rid of the modal dialog that blocks using the window.

此错误消息来自 OmniPascalServer.exe 随 VSCode 的 OmniPascal 插件一起提供,(当前)版本 0.10.0 于 2016 年 4 月 14 日发布。

版本 < 0.11.0 的解决方法

据我所知,只有在 Visual Studio 代码而不是文件夹 中打开 文件时才会出现此错误消息。因此,最简单的解决方法是打开包含您要使用的文件的文件夹:

  • 通过命令行:输入code C:\Projects\MyProjectRootFolder
  • 使用 Windows Explorer: 右键单击​​文件夹(或文件夹内的白色区域)并 select 打开代码不要select打开.pas文件VSCode!
  • 从 VSCode 中:转到 File -> Open Folder...

或应用修补程序

  • 打开文件 C:\Users\USERNAME\.vscode\extensions\Wosi.omnipascal-0.10.0\objectPascalServiceClient.js
  • 替换此行

    var workspacePath = vscode.workspace.rootPath;
    

    这些行

    var workspacePath = vscode.workspace.rootPath;
    if (typeof workspacePath == 'undefined') {
        var filePath = vscode.workspace.textDocuments[0].fileName;
        workspacePath = path.dirname(filePath);
    } 
    

现在错误应该不会再出现了。