Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when using livePreview.start.preview.atFile with an argument #384

Closed
junalmeida opened this issue Dec 7, 2022 · 5 comments
Closed

Comments

@junalmeida
Copy link

junalmeida commented Dec 7, 2022

I get the following error message when I try to use the command livePreview.start.preview.atFile with one string argument representing a workspace file. Either absolute or relative path doesn't work.

Window log

2022-12-07 08:20:39.973 [error] [Extension Host] Tried to open a non-file URI with file opener
2022-12-07 08:20:40.025 [error] An unknown error occurred. Please consult the log for more details.: Error: An unknown error occurred. Please consult the log for more details.
	at s._executeContributedCommand (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:92:111561)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)

Extension Host log

2022-12-07 08:20:39.972 [error] Error: 
	at S.cmp (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:64:12872)
	at I.findSubstr (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:64:16911)
	at R.getWorkspaceFolder (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:103:16286)
	at M.getWorkspaceFolder (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:103:19250)
	at Object.getWorkspaceFolder (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:113:46819)
	at b.handleOpenFile (c:\Users\junior\.vscode\extensions\ms-vscode.live-server-0.4.4\out\extension.js:1:63068)
	at b.openPreviewAtFileUri (c:\Users\junior\.vscode\extensions\ms-vscode.live-server-0.4.4\out\extension.js:1:65978)
	at c:\Users\junior\.vscode\extensions\ms-vscode.live-server-0.4.4\out\extension.js:1:480357
	at s._executeContributedCommand (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:92:111375)
	at s.$executeContributedCommand (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:92:112079)
	at l._doInvokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:102:13680)
	at l._invokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:102:13362)
	at l._receiveRequest (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:102:12132)
	at l._receiveOneMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:102:10834)
	at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:102:8941
	at h.invoke (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:61:145)
	at v.deliver (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:61:2266)
	at g.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:61:1844)
	at r.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:70:16515)
	at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:118:17104
	at h.invoke (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:61:145)
	at v.deliver (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:61:2266)
	at g.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:61:1844)
	at r.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:70:16515)
	at o._receiveMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:70:21327)
	at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:70:18770
	at h.invoke (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:61:145)
	at v.deliver (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:61:2266)
	at g.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:61:1844)
	at g.acceptChunk (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:70:13346)
	at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:70:12476
	at Socket.i (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:70:24594)
	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) livePreview.start.preview.atFile {"value":"ms-vscode.live-server","_lower":"ms-vscode.live-server"}

Steps to recreate

Create the following tasks.json:

{
    "version": "2.0.0",
    "tasks": [        {
            "label": "test",
            "command": "${input:preview-test}",
            "problemMatcher": []
        }],
    "inputs": [
        {
            "id": "preview-test",
            "type": "command",
            "command": "livePreview.start.preview.atFile",
            "args": "any-file.html" // I also have tried [ "str" ]  and { "file": "str" }
        }
    ]
}

Run task "test"

@junalmeida
Copy link
Author

It seems it also affects Coverage Gutters extension that uses live-preview as a dependency.
ryanluker/vscode-coverage-gutters#381

@andreamah
Copy link
Contributor

A commit a while ago (d8630f6) changed the argument to start.preview.atFile to be vscode.URI to reduce the messy logic of deducing absolute/relative paths that was there before.

@andreamah
Copy link
Contributor

It looks like there's currently no way to pass a URI as an argument in tasks.json, so unfortunately, it'd be hard to run the command that way. If it's just one common path, you could just set livePreview.defaultPreviewPath in settings and running Live Preview: Start Server will default to that path.

@junalmeida
Copy link
Author

@andreamah Thanks for the idea but it has no use on my scenario.

@andreamah
Copy link
Contributor

I think you have a valid use-case (and I wasn't too aware of using the command like that before) so I created #388.

kaltepeter added a commit to kaltepeter/vscode-coverage-gutters that referenced this issue Feb 25, 2023
closes ryanluker#381

convert file path string to vscode.Uri to support changes in live
preview

resovles the exception mentioned in microsoft/vscode-livepreview#384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants