Skip to content

Commit 8786fca

Browse files
committed
Revert "Fix unified definition navigation and Ctrl+Click local resolution (#32)"
This reverts commit dd066d5.
1 parent abe7f90 commit 8786fca

File tree

7 files changed

+65
-193
lines changed

7 files changed

+65
-193
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,11 @@
538538
}
539539
],
540540
"editor/title": [
541+
{
542+
"command": "vscode-objectscript.ccs.goToDefinition",
543+
"group": "navigation@0",
544+
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
545+
},
541546
{
542547
"command": "-editor.action.revealDefinition",
543548
"group": "navigation@0",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as vscode from "vscode";
2+
3+
import { lookupCcsDefinition } from "../features/definitionLookup/lookup";
4+
5+
export async function followDefinitionLink(documentUri: string, line: number, character: number): Promise<void> {
6+
if (!documentUri || typeof line !== "number" || typeof character !== "number") {
7+
return;
8+
}
9+
10+
const uri = vscode.Uri.parse(documentUri);
11+
const document =
12+
vscode.workspace.textDocuments.find((doc) => doc.uri.toString() === documentUri) ??
13+
(await vscode.workspace.openTextDocument(uri));
14+
15+
const position = new vscode.Position(line, character);
16+
const tokenSource = new vscode.CancellationTokenSource();
17+
18+
try {
19+
const location = await lookupCcsDefinition(document, position, tokenSource.token);
20+
if (location) {
21+
await vscode.window.showTextDocument(location.uri, { selection: location.range });
22+
return;
23+
}
24+
25+
await vscode.window.showTextDocument(document, {
26+
selection: new vscode.Range(position, position),
27+
});
28+
await vscode.commands.executeCommand("editor.action.revealDefinition");
29+
} finally {
30+
tokenSource.dispose();
31+
}
32+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as vscode from "vscode";
2+
3+
import { lookupCcsDefinition } from "../features/definitionLookup/lookup";
4+
5+
export async function goToDefinitionLocalFirst(): Promise<void> {
6+
const editor = vscode.window.activeTextEditor;
7+
if (!editor) {
8+
return;
9+
}
10+
11+
const { document, selection } = editor;
12+
const position = selection.active;
13+
const tokenSource = new vscode.CancellationTokenSource();
14+
15+
try {
16+
const location = await lookupCcsDefinition(document, position, tokenSource.token);
17+
if (location) {
18+
await vscode.window.showTextDocument(location.uri, { selection: location.range });
19+
return;
20+
}
21+
} finally {
22+
tokenSource.dispose();
23+
}
24+
25+
await vscode.commands.executeCommand("editor.action.revealDefinition");
26+
}

src/ccs/commands/navigation/followDefinitionLink.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/ccs/commands/navigation/goToDefinitionLocalFirst.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/ccs/commands/navigation/navigateDefinition.ts

Lines changed: 0 additions & 148 deletions
This file was deleted.

src/ccs/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ export {
1313
type QueryMatch,
1414
type QueryKind,
1515
} from "./features/definitionLookup/extractQuery";
16-
export { goToDefinitionLocalFirst } from "./commands/navigation/goToDefinitionLocalFirst";
17-
export { followDefinitionLink } from "./commands/navigation/followDefinitionLink";
18-
export { navigateToDefinition, type NavigateOpts } from "./commands/navigation/navigateDefinition";
16+
export { goToDefinitionLocalFirst } from "./commands/goToDefinitionLocalFirst";
17+
export { followDefinitionLink } from "./commands/followDefinitionLink";
1918
export { PrioritizedDefinitionProvider } from "./providers/PrioritizedDefinitionProvider";
2019
export {
2120
DefinitionDocumentLinkProvider,

0 commit comments

Comments
 (0)