Theia: "window.showTextDocument" Does Not open Resources With "untitled" Scheme

Created on 17 Nov 2019  路  11Comments  路  Source: eclipse-theia/theia

Description

Using SQLTools extension (0.21.3), https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools.
When trying to connect to a db at the first time, SQLite dependency is installed.
The dependency can be installed automatically if using in User preferences:

"sqltools.dependencyManager": {
        "autoAccept": true
    }

Based on https://github.com/mtxr/vscode-sqltools/releases/tag/v0.21.2.

In vscode no error apears, yet in gitprod the following error notification appears:
SQLTools - Error installing dependency SQLite

Reproduction Steps

  1. Download SQLTools extension (current version 0.21.3)
  2. Create in workspace/theia a new file called "tom.db".
  3. Add to User preferences the following values:
{
    "sqltools.useNodeRuntime": true,
    "sqltools.dependencyManager": {
        "autoAccept": true
    },
    "sqltools.connections": [
        {
            "name": "sqlite",
            "dialect": "SQLite",
            "database": "workspace/theia/tom.db"
        }
    ]
}

image

  1. Click on SQLTools extension. In "sqlite" linem, click on connect:
    image

  2. Expect the error notification displayed in the Description section to appear.

OS and Theia version:

Diagnostics:
SQLTools - Error installing dependency SQLite
SQLTools - Error installing dependency SQLite - Log Info

bug help wanted vscode

Most helpful comment

I think we found the gap.

This is a minimal code that reproduce it:

const uri = vscode.Uri.file(os.homedir + '/newnew.txt');
const fileUri = vscode.Uri.parse(`untitled:${uri}`).with({ scheme: 'untitled' });
vscode.window.showTextDocument(fileUri);

We tried it with hosted theia. The editor doesn't open and we get this error on theia:

root ERROR [hosted-plugin: 9850] Promise rejection not handled in one second: Error: TypeError: Cannot read property 'dispose' of undefined
root ERROR [hosted-plugin: 9850] With stack trace: Error: TypeError: Cannot read property 'dispose' of undefined
    at e.<anonymous> (https://webide-workspaces-ws-qwkth-app5.cry10.int.webide.cloud.sap/bundle.js:19:785104)
    at https://webide-workspaces-ws-qwkth-app5.cry10.int.webide.cloud.sap/bundle.js:19:781329
    at Object.throw (https://webide-workspaces-ws-qwkth-app5.cry10.int.webide.cloud.sap/bundle.js:19:781434)
    at s (https://webide-workspaces-ws-qwkth-app5.cry10.int.webide.cloud.sap/bundle.js:19:780231)

On VS Code this code opens a new tab with unsaved document newnew.txt.

All 11 comments

It would be helpful if someone investigates what is missing.

@TomHermanSAP and me are investigating.

I think we found the gap.

This is a minimal code that reproduce it:

const uri = vscode.Uri.file(os.homedir + '/newnew.txt');
const fileUri = vscode.Uri.parse(`untitled:${uri}`).with({ scheme: 'untitled' });
vscode.window.showTextDocument(fileUri);

We tried it with hosted theia. The editor doesn't open and we get this error on theia:

root ERROR [hosted-plugin: 9850] Promise rejection not handled in one second: Error: TypeError: Cannot read property 'dispose' of undefined
root ERROR [hosted-plugin: 9850] With stack trace: Error: TypeError: Cannot read property 'dispose' of undefined
    at e.<anonymous> (https://webide-workspaces-ws-qwkth-app5.cry10.int.webide.cloud.sap/bundle.js:19:785104)
    at https://webide-workspaces-ws-qwkth-app5.cry10.int.webide.cloud.sap/bundle.js:19:781329
    at Object.throw (https://webide-workspaces-ws-qwkth-app5.cry10.int.webide.cloud.sap/bundle.js:19:781434)
    at s (https://webide-workspaces-ws-qwkth-app5.cry10.int.webide.cloud.sap/bundle.js:19:780231)

On VS Code this code opens a new tab with unsaved document newnew.txt.

Seems like "untitled" scheme does not have a "ResourceResolver", for example as File Resource has:
https://github.com/eclipse-theia/theia/blob/master/packages/filesystem/src/browser/file-resource.ts#L143

Do you know why the untitled file created by this method: "createUntitledResource"https://github.com/eclipse-theia/theia/blob/e147cf39c7f484374b7ec0cd0d04958c3ef00bca/packages/plugin-ext/src/main/browser/editor/untitled-resource.ts#L49
is read-only one?

@akosyakov after investigation, there seems to be 2 options to proceed:

  1. "UntitledResourceResolver" - add support to create files in file systems
  2. Direct 'untitled' schema typed files to be resolved by the "FileResourceResolver" somehow.
    We tried and currently it cannot find files because it is concatenating 'untitiled' to file url, as seen here:
root ERROR [hosted-plugin: 18608] With stack trace: Error: Error: 'untitled:file%3A///c%3A/Users/sss/newnew.txt' has not been found.
    at DocumentsMainImpl.<anonymous> (http://localhost:3000/47.bundle.js:338:31)
    at step (http://localhost:3000/47.bundle.js:153:23)
    at Object.throw (http://localhost:3000/47.bundle.js:134:53)
    at rejected (http://localhost:3000/47.bundle.js:126:65)

Do you have a proposal how to continue?

"UntitledResourceResolver" - add support to create files in file systems

@offer8 Can it be implemented by delegating to FileResourceResolver? i.e. whenever saveContents is called a user is prompted to save a file and then an instance of FileResource is created, to which UntitledResource delegates all calls

@amiramw @TomHermanSAP @offer8 Could you test https://github.com/eclipse-theia/theia/pull/6803 please?

@akosyakov can this one be part of v0.16.0 release?

it's in the master and 0.16.0 was not released yet so why not?

Was this page helpful?
0 / 5 - 0 ratings