Skip to content

Commit 2fcd0b8

Browse files
authored
Merge pull request #629 from ty-d/UseDocSymbolProviderInJump
Update Jump to Tag + Offset to use DocumentSymbolProvider
2 parents 25c57f6 + ffcf915 commit 2fcd0b8

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/commands/jumpToTagAndOffset.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ export async function jumpToTagAndOffset(): Promise<void> {
1616
return;
1717
}
1818

19-
// Build map of labels in routine
20-
const map = new Map();
21-
const options = [];
22-
for (let i = 0; i < document.lineCount; i++) {
23-
const labelMatch = document.lineAt(i).text.match(/^(%?\w+).*/);
24-
if (labelMatch) {
25-
map.set(labelMatch[1], i);
26-
options.push(labelMatch[1]);
27-
}
28-
}
29-
30-
const items: vscode.QuickPickItem[] = options.map((option) => {
31-
return { label: option };
32-
});
19+
// Get the labels from the document symbol provider
20+
const map = new Map<string, number>();
21+
const symbols: vscode.DocumentSymbol[] = await vscode.commands.executeCommand(
22+
"vscode.executeDocumentSymbolProvider",
23+
document.uri
24+
);
25+
const items: vscode.QuickPickItem[] = symbols
26+
.filter((symbol) => symbol.kind === vscode.SymbolKind.Method)
27+
.map((symbol) => {
28+
map.set(symbol.name, symbol.range.start.line);
29+
return {
30+
label: symbol.name,
31+
};
32+
});
3333
const quickPick = vscode.window.createQuickPick();
3434
quickPick.title = "Jump to Tag + Offset";
3535
quickPick.items = items;
@@ -50,7 +50,7 @@ export async function jumpToTagAndOffset(): Promise<void> {
5050
return;
5151
}
5252
} else {
53-
offset += parseInt(map.get(parts[0]), 10);
53+
offset += map.get(parts[0]);
5454
}
5555
if (parts.length > 1) {
5656
offset += parseInt(parts[1], 10);

0 commit comments

Comments
 (0)