How to use the @theia/editor/lib/browser/diff-uris.DiffUris.decode function in @theia/editor

To help you get started, we’ve selected a few @theia/editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / monaco / src / browser / monaco-editor-provider.ts View on Github external
async get(uri: URI): Promise {
        await this.editorPreferences.ready;

        let editor: MonacoEditor;
        const toDispose = new DisposableCollection();

        if (!DiffUris.isDiffUri(uri)) {
            const model = await this.getModel(uri, toDispose);

            editor = this.createEditor((node, override) => new MonacoEditor(
                uri, model, node, this.m2p, this.p2m, this.getEditorOptions(model), override
            ), toDispose);

        } else {
            const [original, modified] = DiffUris.decode(uri);

            const originalModel = await this.getModel(original, toDispose);
            const modifiedModel = await this.getModel(modified, toDispose);

            editor = this.createEditor((node, override) => new MonacoDiffEditor(
                node,
                originalModel,
                modifiedModel,
                this.m2p,
                this.p2m,
                this.getDiffEditorOptions(originalModel, modifiedModel),
                override
            ), toDispose);
        }

        return Promise.resolve(editor);