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

Commit 8463674

Browse files
committed
fix highlight issues, microsoft/vscode#97881
1 parent affc14d commit 8463674

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Reference Search View",
44
"icon": "media/icon.png",
55
"description": "Reference Search results as separate, stable view in the sidebar",
6-
"version": "0.0.54",
6+
"version": "0.0.55",
77
"publisher": "ms-vscode",
88
"engines": {
99
"vscode": "^1.40.0"

src/extension.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export function activate(context: vscode.ExtensionContext) {
280280
stack.push(...(await item.items).slice(0, 99));
281281

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

src/models.ts

+15-14
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,38 @@ export const enum ItemSource {
5656

5757
export class FileItem {
5858

59-
private _document: Thenable<vscode.TextDocument> | undefined;
60-
6159
constructor(
6260
readonly uri: vscode.Uri,
6361
readonly results: Array<ReferenceItem>,
6462
readonly parent: ReferencesModel
6563
) { }
64+
}
65+
66+
export class ReferenceItem {
67+
68+
private _document: Thenable<vscode.TextDocument> | undefined;
69+
70+
constructor(
71+
readonly location: vscode.Location,
72+
readonly parent: FileItem,
73+
) { }
6674

6775
async getDocument(warmUpNext?: boolean) {
6876
if (!this._document) {
69-
this._document = vscode.workspace.openTextDocument(this.uri);
77+
this._document = vscode.workspace.openTextDocument(this.location.uri);
7078
}
7179
if (warmUpNext) {
7280
// load next document once this document has been loaded
7381
// and when next document has not yet been loaded
74-
const item = await this.parent.move(this, true);
75-
if (item && !item.parent._document) {
76-
this._document.then(() => item.parent.getDocument(false));
82+
const item = await this.parent.parent.move(this, true);
83+
if (item && !item._document) {
84+
this._document.then(() => item.getDocument(false));
7785
}
7886
}
7987
return this._document;
8088
}
8189
}
8290

83-
export class ReferenceItem {
84-
constructor(
85-
readonly location: vscode.Location,
86-
readonly parent: FileItem,
87-
) { }
88-
}
89-
9091
export class ReferencesModel {
9192

9293
static create(uri: vscode.Uri, position: vscode.Position, source: ItemSource): ReferencesModel {
@@ -113,7 +114,7 @@ export class ReferencesModel {
113114
locations.sort(ReferencesModel._compareLocations);
114115
for (const loc of locations) {
115116
if (!last || ReferencesModel._compareUriIgnoreFragment(last.uri, loc.uri) !== 0) {
116-
last = new FileItem(loc.uri, [], this);
117+
last = new FileItem(loc.uri.with({ fragment: '' }), [], this);
117118
items.push(last);
118119
}
119120
last.results.push(new ReferenceItem(loc, last));

src/provider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class ReferencesProvider implements vscode.TreeDataProvider<FileItem | Re
3939
} else {
4040
// references
4141
const { range } = element.location;
42-
const doc = await element.parent.getDocument(true);
42+
const doc = await element.getDocument(true);
4343
const { before, inside, after } = getPreviewChunks(doc, range);
4444

4545
const label: vscode.TreeItemLabel = {

0 commit comments

Comments
 (0)