Skip to content

Commit

Permalink
Fixed compare editor when working with dirty files
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
Akos Kitta authored and kittaakos committed Mar 12, 2021
1 parent 9ddb367 commit 6afae44
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,14 @@ export class SearchInWorkspaceResultTreeWidget extends TreeWidget {

protected async createReplacePreview(node: SearchInWorkspaceFileNode): Promise<URI> {
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 => {
Expand Down

0 comments on commit 6afae44

Please sign in to comment.