Vscode: Allow to open non-text files via API

Created on 24 Nov 2015  路  11Comments  路  Source: microsoft/vscode

_From @ArtemGovorov on November 17, 2015 3:8_

I can open an image (PNG) in the editor manually and there's workspace.openTextDocument, but, as expected from the function name, I can't use it to open the image file: "cannot open file:///.... Detail: File seems to be binary and cannot be opened as text". Perhaps there should be another function, such as openFile that could open any supported file type?

_Copied from original issue: Microsoft/vscode-extensionbuilders#117_

api feature-request

Most helpful comment

@jrieken Thanks! No rush, I think I found a good alternative by essentially wrapping the image into an HTML page and displaying the HTML document with the vscode.previewHtml command (and custom content provider).

vsc

All 11 comments

_From @jrieken on November 18, 2015 13:16_

I like. Idea is to make the underlying command we already have so that it can accept an uri executeCommand

Progress so far?

Wallabyjs offers the ability to display a screenshot of the last screen in the unit test in other GUIs (WebStorm, etc.). We really want this functionality in our preferred code editor VSCode as well.

I'll see what June allows

@jrieken Thanks! No rush, I think I found a good alternative by essentially wrapping the image into an HTML page and displaying the HTML document with the vscode.previewHtml command (and custom content provider).

vsc

previewHtml FTW

Awesome!

Fantastic!

@bpasero Is this low hanging? Can I use the usual trick with a ResourceEditorInput?

No, because it's resolve method will try to make a text editor model out of it (https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/common/editor/resourceEditorInput.ts#L159)

But from the workbench point of view you can pass in a file:/// URI pointing to an image and it will open as image. So I think everything should just work if you end up calling IEditorService.openEditor.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

curtw picture curtw  路  3Comments

borekb picture borekb  路  3Comments

vsccarl picture vsccarl  路  3Comments

sirius1024 picture sirius1024  路  3Comments

lukehoban picture lukehoban  路  3Comments