How to use the @theia/languages/lib/browser.TextEdit.replace function in @theia/languages

To help you get started, we’ve selected a few @theia/languages 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 / merge-conflicts / src / browser / merge-conflict-resolver.ts View on Github external
protected async doAccept(argument: MergeConflictCommandArgument,
        newTextFn: ((textOfRange: (range: Range | undefined) => string, conflict: MergeConflict) => string)): Promise {
        const { uri, conflict } = argument;
        const editorWidget = await this.editorManager.getByUri(new URI(uri));
        if (!editorWidget) {
            return;
        }
        const newText = newTextFn(range => this.getTextRange(range, editorWidget.editor.document), conflict);
        editorWidget.editor.executeEdits([TextEdit.replace(conflict.total!, newText)]);
    }
github eclipse-theia / theia / packages / debug / src / browser / console / debug-console-session.ts View on Github external
protected asCompletionItem(document: TextDocument, position: Position, prefixLength: number, item: DebugProtocol.CompletionItem): CompletionItem {
        const { label, text, type, length } = item;
        const newText = text || label;
        const start = document.positionAt(document.offsetAt(position) - (length || prefixLength));
        const replaceRange = Range.create(start, position);
        const textEdit = TextEdit.replace(replaceRange, newText);
        return {
            label,
            textEdit,
            kind: this.completionKinds.get(type)
        };
    }