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

Commit e0955a0

Browse files
committed
1 parent a505658 commit e0955a0

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
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.45",
6+
"version": "0.0.46",
77
"publisher": "ms-vscode",
88
"engines": {
99
"vscode": "^1.40.0"

src/extension.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as vscode from 'vscode';
77
import { EditorHighlights } from './editorHighlights';
88
import { History, HistoryItem } from './history';
9-
import { CallItem, CallsDirection, CallsModel, FileItem, getPreviewChunks, ItemSource, ReferenceItem, ReferencesModel, RichCallsDirection } from './models';
9+
import { CallItem, CallsDirection, CallsModel, FileItem, getPreviewChunks, getRequestRange, ItemSource, ReferenceItem, ReferencesModel, RichCallsDirection } from './models';
1010
import { TreeDataProviderWrapper, TreeItem } from './provider';
1111

1212
export function activate(context: vscode.ExtensionContext) {
@@ -135,7 +135,7 @@ export function activate(context: vscode.ExtensionContext) {
135135
} else if (vscode.window.activeTextEditor) {
136136
// take args from active editor
137137
let editor = vscode.window.activeTextEditor;
138-
if (editor.document.getWordRangeAtPosition(editor.selection.active)) {
138+
if (getRequestRange(editor.document, editor.selection.active)) {
139139
model = ReferencesModel.create(editor.document.uri, editor.selection.active, source);
140140
}
141141
}
@@ -166,7 +166,7 @@ export function activate(context: vscode.ExtensionContext) {
166166
} else if (vscode.window.activeTextEditor) {
167167
// take args from active editor
168168
let editor = vscode.window.activeTextEditor;
169-
if (editor.document.getWordRangeAtPosition(editor.selection.active)) {
169+
if (getRequestRange(editor.document, editor.selection.active)) {
170170
model = new CallsModel(editor.document.uri, editor.selection.active, direction);
171171
}
172172
}

src/models.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
import * as vscode from 'vscode';
77
import { HistoryItem } from './history';
88

9+
10+
export function getRequestRange(doc: vscode.TextDocument, pos: vscode.Position): vscode.Range | undefined {
11+
let range = doc.getWordRangeAtPosition(pos);
12+
if (!range) {
13+
range = doc.getWordRangeAtPosition(pos, /[^\s]+/);
14+
}
15+
return range;
16+
}
17+
918
export function getPreviewChunks(doc: vscode.TextDocument, range: vscode.Range, beforeLen: number = 8, trim: boolean = true) {
1019
let previewStart = range.start.with({ character: Math.max(0, range.start.character - beforeLen) });
1120
let wordRange = doc.getWordRangeAtPosition(previewStart);
@@ -109,7 +118,7 @@ export class ReferencesModel {
109118
} catch (e) {
110119
return;
111120
}
112-
const range = doc.getWordRangeAtPosition(this.position);
121+
const range = getRequestRange(doc, this.position);
113122
if (!range) {
114123
return;
115124
}

0 commit comments

Comments
 (0)