Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)]);
}
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)
};
}