From 6afae440e13d126174db7b560b2ef3ad15b9d5ef Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Fri, 12 Mar 2021 13:03:01 +0100 Subject: [PATCH] Fixed compare editor when working with dirty files Signed-off-by: Akos Kitta --- .../browser/search-in-workspace-result-tree-widget.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx b/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx index c7310761618ce..fb91d5f7396a2 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx +++ b/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx @@ -989,8 +989,14 @@ export class SearchInWorkspaceResultTreeWidget extends TreeWidget { protected async createReplacePreview(node: SearchInWorkspaceFileNode): Promise { const fileUri = new URI(node.fileUri).withScheme('file'); - const resource = await this.fileResourceResolver.resolve(fileUri); - const content = await resource.readContents(); + const openedEditor = this.editorManager.all.find(({ editor }) => editor.uri.toString() === fileUri.toString()); + let content: string; + if (openedEditor) { + content = openedEditor.editor.document.getText(); + } else { + const resource = await this.fileResourceResolver.resolve(fileUri); + content = await resource.readContents(); + } const lines = content.split('\n'); node.children.map(l => {