saem/vscode-nim

Defining a project file that doesn't exist breaks autosuggest with nimsuggest

izackp opened this issue · 2 comments

{
    "nim.logNimsuggest": true,
    "nim.lintOnSave": true,
    "nim.useNimsuggestCheck": true,
    "nim.buildOnSave": true,
    "nim.buildCommand": "c",
    "nim.project": ["src/TestZone.nim"]
}

lets say "src/TestZone.nim doesn't exist. NimSuggest will immediately close and there is no error handling inside of nimSuggestExec.nim

I tried modifying the code a bit

process.stderr.onceData(proc(data: Buffer) =
        let error = data.toString()
        console.log("getNimSuggestProcess - stderr pid: ", process.pid, "data:",
            error)
        if (error.contains("cannot find file")):
          reject((fmt"Nimsuggest can not start: {error}").toJs())
      )

It eventually fires an exception (with null details).. Ideally the plugin should display the error to the user via outputLine()

saem commented

Ok that's not good at all. 😅

Yeah, it should really report an error the whole "will exceptions work today across the nim/JS boundary" is a whole thing. Might be a tiny slow down in debugging, can you check on stdout as well in case nimsuggest didn't use stderr?

I'm guessing you already know this, but just in case: Launching a debug build of the extension, see the readme, basically comes down to clone this repo, npm install, open the cone in VSCode, add in console.log spam, and press F5. Will show messages in the debug console.

I'm guessing the process handling code just isn't failing the promise with any error info and if it did that's already going to be much better.

This is what prints in the console with the code unmodified.

(node:39882) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `Code Helper (Renderer) --trace-deprecation ...` to show where the warning was created)
,Nim Compiler Version 1.6.0 [MacOSX: arm64]
Compiled at 2021-10-19
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release -d:danger --gc:markAndSweep
,
Nimsuggest version: null
ExtensionContext:
        extensionPath:/Users/isaacpaul/Projects/nim/vscode-nim
        storagePath:/Users/isaacpaul/Library/Application Support/Code/User/workspaceStorage/59ba3820841b063c43f96b071408899f/nimsaem.nimvscode
        logPath:/Users/isaacpaul/Library/Application Support/Code/logs/20211104T165809/exthost10/nimsaem.nimvscode
execNimSuggest - filename /Users/isaacpaul/Projects/nim/midi-parser/src/midiparser.nim projectFile {wsFolder: {…}, filePath: 'src/TestZone.nim'}
arg3: {wsFolder: {…}, filePath: 'src/TestZone.nim'}
filePath: 'src/TestZone.nim'
wsFolder: {uri: w, name: 'midi-parser', index: 0}
index: 0
name: 'midi-parser'
uri: w {scheme: 'file', authority: '', path: '/Users/isaacpaul/Projects/nim/midi-parser', query: '', fragment: '', …}
__proto__: Object
__proto__: Object
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
valueOf: ƒ valueOf()
__defineGetter__: ƒ __defineGetter__()
__defineSetter__: ƒ __defineSetter__()
__lookupGetter__: ƒ __lookupGetter__()
__lookupSetter__: ƒ __lookupSetter__()
__proto__ (get): ƒ __proto__()
__proto__ (set): ƒ __proto__()
started nimsuggest process (39904)) args: (--epc --v2 --log --refresh:on src/TestZone.nim) cwd: /Users/isaacpaul/Projects/nim/midi-parser nim project: {wsFolder: {…}, filePath: 'src/TestZone.nim'}
Reset nimsuggest process each 60 minutes
getNimSuggestProcess - stderr pid:  39904 data: cannot find file: src/TestZone.nim
exclude globs:  {**/.git/objects/**,**/.git/subtree-cache/**,**/node_modules/*/**,**/.hg/store/**}
Indexing, file count: 3
indexing:  0 w {scheme: 'file', authority: '', path: '/Users/isaacpaul/Projects/nim/midi-parser/tests/test1.nim', query: '', fragment: '', …}
getFileSymbols - execnimsuggest - useDirtyFile outline /Users/isaacpaul/Projects/nim/midi-parser/tests/test1.nim false
execNimSuggest - filename /Users/isaacpaul/Projects/nim/midi-parser/tests/test1.nim projectFile {wsFolder: {…}, filePath: 'src/TestZone.nim'}
[CMakeTools] 2021-11-05T22:36:06.962Z [debug] [main] Safe constructing new CMakeTools instance
[CMakeTools] 2021-11-05T22:36:06.962Z [debug] [variant] Constructing VariantManager
[CMakeTools] 2021-11-05T22:36:06.963Z [debug] [main] Constructing new CMakeTools instance
[CMakeTools] 2021-11-05T22:36:06.964Z [debug] [main] Starting CMakeTools second-phase init
[CMakeTools] 2021-11-05T22:36:06.999Z [info] [variant] Loaded new set of variants
[CMakeTools] 2021-11-05T22:36:07.000Z [debug] [main] CMakeTools instance initialization complete.
[CMakeTools] 2021-11-05T22:36:07.001Z [debug] [kit] Reading kits file /Users/isaacpaul/.local/share/CMakeTools/cmake-tools-kits.json
[CMakeTools] 2021-11-05T22:36:07.012Z [info] [kit] Successfully loaded 1 kits from /Users/isaacpaul/.local/share/CMakeTools/cmake-tools-kits.json
[CMakeTools] 2021-11-05T22:36:07.015Z [debug] [kit] Not reading non-existent kits file: /Users/isaacpaul/Projects/nim/midi-parser/.vscode/cmake-kits.json
getDocumentSymbols - execnimsuggest - useDirtyFile outline /Users/isaacpaul/Projects/nim/midi-parser/src/midiparser.nim true
execNimSuggest - filename /Users/isaacpaul/Projects/nim/midi-parser/src/midiparser.nim projectFile {wsFolder: {…}, filePath: 'src/TestZone.nim'}
[CMakeTools] 2021-11-05T22:36:15.007Z [debug] [extension] Not updating the configuration provider because C_Cpp.intelliSenseEngine is set to 'Disabled'
getDocumentSymbols - execnimsuggest - useDirtyFile outline /Users/isaacpaul/Projects/nim/midi-parser/src/midiparser.nim true
execNimSuggest - filename /Users/isaacpaul/Projects/nim/midi-parser/src/midiparser.nim projectFile {wsFolder: {…}, filePath: 'src/TestZone.nim'}
execNimSuggest - filename /Users/isaacpaul/Projects/nim/midi-parser/src/midiparser.nim projectFile {wsFolder: {…}, filePath: 'src/TestZone.nim'}