Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
fix highlight issues, microsoft/vscode#97881
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed May 15, 2020
1 parent affc14d commit 8463674
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Reference Search View",
"icon": "media/icon.png",
"description": "Reference Search results as separate, stable view in the sidebar",
"version": "0.0.54",
"version": "0.0.55",
"publisher": "ms-vscode",
"engines": {
"vscode": "^1.40.0"
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export function activate(context: vscode.ExtensionContext) {
stack.push(...(await item.items).slice(0, 99));

} else if (item instanceof ReferenceItem) {
let doc = await item.parent.getDocument();
let doc = await item.getDocument();
let chunks = getPreviewChunks(doc, item.location.range, 21, false);
val += ` ${item.location.range.start.line + 1}, ${item.location.range.start.character + 1}: ${chunks.before + chunks.inside + chunks.after} \n`;

Expand Down
29 changes: 15 additions & 14 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,37 +56,38 @@ export const enum ItemSource {

export class FileItem {

private _document: Thenable<vscode.TextDocument> | undefined;

constructor(
readonly uri: vscode.Uri,
readonly results: Array<ReferenceItem>,
readonly parent: ReferencesModel
) { }
}

export class ReferenceItem {

private _document: Thenable<vscode.TextDocument> | undefined;

constructor(
readonly location: vscode.Location,
readonly parent: FileItem,
) { }

async getDocument(warmUpNext?: boolean) {
if (!this._document) {
this._document = vscode.workspace.openTextDocument(this.uri);
this._document = vscode.workspace.openTextDocument(this.location.uri);
}
if (warmUpNext) {
// load next document once this document has been loaded
// and when next document has not yet been loaded
const item = await this.parent.move(this, true);
if (item && !item.parent._document) {
this._document.then(() => item.parent.getDocument(false));
const item = await this.parent.parent.move(this, true);
if (item && !item._document) {
this._document.then(() => item.getDocument(false));
}
}
return this._document;
}
}

export class ReferenceItem {
constructor(
readonly location: vscode.Location,
readonly parent: FileItem,
) { }
}

export class ReferencesModel {

static create(uri: vscode.Uri, position: vscode.Position, source: ItemSource): ReferencesModel {
Expand All @@ -113,7 +114,7 @@ export class ReferencesModel {
locations.sort(ReferencesModel._compareLocations);
for (const loc of locations) {
if (!last || ReferencesModel._compareUriIgnoreFragment(last.uri, loc.uri) !== 0) {
last = new FileItem(loc.uri, [], this);
last = new FileItem(loc.uri.with({ fragment: '' }), [], this);
items.push(last);
}
last.results.push(new ReferenceItem(loc, last));
Expand Down
2 changes: 1 addition & 1 deletion src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ReferencesProvider implements vscode.TreeDataProvider<FileItem | Re
} else {
// references
const { range } = element.location;
const doc = await element.parent.getDocument(true);
const doc = await element.getDocument(true);
const { before, inside, after } = getPreviewChunks(doc, range);

const label: vscode.TreeItemLabel = {
Expand Down

0 comments on commit 8463674

Please sign in to comment.