ionide / ionide-vscode-fsharp

VS Code plugin for F# development
http://ionide.io
MIT License
865 stars 279 forks source link

Error on Add file above or below #1783

Closed somelinguist closed 2 years ago

somelinguist commented 2 years ago

Describe the bug

After installing 7.2.0, when trying to add a file above another file in the solution explorer, I get the following error:

Error running command fsharp.explorer.addAbove: copyOfStruct is not defined. This is likely caused by the extension that contributes fsharp.explorer.addAbove.

Pretty much the same with Add file below:

Error running command fsharp.explorer.addBelow: copyOfStruct is not defined. This is likely caused by the extension that contributes fsharp.explorer.addBelow.

Downgrading to Ionide 7.1.0 solves this particular issue for now.

Steps to reproduce

  1. Right click on a file in F#: Solution Explorer and choose Add file above or Add file below.

Machine info

OnurGumus commented 2 years ago

Same here, broken with 7.2

somelinguist commented 2 years ago

Not sure if this is helpful, but adding the trace log just in case:

[2022-09-30 20:50:39.871] [exthost] [error] ReferenceError: copyOfStruct is not defined
    at N.setter (/Users/kevin/.vscode/extensions/ionide.ionide-fsharp-7.2.2/fsharp.js:2:750343)
    at set contents [as contents] (/Users/kevin/.vscode/extensions/ionide.ionide-fsharp-7.2.2/fsharp.js:2:615502)
    at Ol (/Users/kevin/.vscode/extensions/ionide.ionide-fsharp-7.2.2/fsharp.js:2:750357)
    at /Users/kevin/.vscode/extensions/ionide.ionide-fsharp-7.2.2/fsharp.js:2:757020
    at /Users/kevin/.vscode/extensions/ionide.ionide-fsharp-7.2.2/fsharp.js:2:757305
    at c._executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:85:63770)
    at c.$executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:85:64474)
    at i._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:95:13689)
    at i._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:95:13371)
    at i._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:95:12141)
    at i._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:95:11042)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:95:8950
    at b.invoke (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:61:145)
    at p.deliver (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:61:2266)
    at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:61:1844)
    at a.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:69:19042)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:17079
    at b.invoke (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:61:145)
    at p.deliver (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:61:2266)
    at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:61:1844)
    at a.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:69:19042)
    at r._receiveMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:69:23854)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:69:21224
    at b.invoke (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:61:145)
    at p.deliver (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:61:2266)
    at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:61:1844)
    at v.acceptChunk (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:69:15873)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:69:15003
    at Socket.d (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:69:26763)
    at Socket.emit (node:events:526:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Readable.push (node:internal/streams/readable:228:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) fsharp.explorer.addAbove {"value":"Ionide.Ionide-fsharp","_lower":"ionide.ionide-fsharp"}
kgday commented 2 years ago

I think this might be the same issue, I get a similar error when clicking on the project -> add file in VSCode. The error: Error running command fsharp.explorer.addFile: copyOfStruct is not defined. This is likely caused by the extension that contributes fsharp.explorer.addFile.

baronfel commented 2 years ago

yep, that's definitely the same root cause. I haven't been able to figure it out yet.

somelinguist commented 2 years ago

It fails before the input box is shown.

I see the way the input box is created in each of these cases was refactored to createFileDialg between 7.1.0 and 7.20. In that function two things that changed in the creation of the input box were:

  1. The addition of a validation function to check if the file already exists
  2. opt.value is no longer set before showing the input box.

I’m not familiar enough with the code to know if either of those changes could be the cause. Sorry for not being able to be more of a help.

https://github.com/ionide/ionide-vscode-fsharp/compare/7.1.0...7.2.0#diff-13ae03b738fb9bcc3ffeb34994ecc2d80e815e98079c87f8e9c0c42fadd2a9d9

MangelMaxime commented 2 years ago

The error seems to be caused by these lines:

https://github.com/ionide/ionide-vscode-fsharp/blob/7059f31e3747a26c7314607bee6f888040bc2f95/src/Components/SolutionExplorer.fs#L631-L660

I am certain that it was working when I contributing the PR, I am not sure what changed.

Still investigating

MangelMaxime commented 2 years ago

Oupsy, it is possible that I modified the binding in the paket-files folders directly but didn't send a PR because I didn't remember this requirements 😅

@baronfel I you

  1. Merge https://github.com/ionide/ionide-vscode-helpers/pull/47
  2. Update the dependency inside of ionide-vscode-fsharp
  3. Re-compile the project, then it should be fixed
baronfel commented 2 years ago

Lovely! I can merge that from mobile, but I'm away from a computer so if you could handle sending an update PR here after it's merged that would be amazing.