Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,6 @@
}
],
"editor/title": [
{
"command": "vscode-objectscript.ccs.goToDefinition",
"group": "navigation@0",
"when": "editorTextFocus && editorLangId =~ /^objectscript/"
},
{
"command": "-editor.action.revealDefinition",
"group": "navigation@0",
Expand Down
12 changes: 11 additions & 1 deletion src/ccs/providers/DefinitionDocumentLinkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export class DefinitionDocumentLinkProvider implements vscode.DocumentLinkProvid
);

return queries.map((match) => {
const args = [document.uri.toString(), match.range.start.line, match.range.start.character];
const targetPosition = this.getDefinitionPosition(match.range);
const args = [document.uri.toString(), targetPosition.line, targetPosition.character];
const commandUri = vscode.Uri.parse(
`command:${followDefinitionLinkCommand}?${encodeURIComponent(JSON.stringify(args))}`
);
Expand All @@ -58,6 +59,15 @@ export class DefinitionDocumentLinkProvider implements vscode.DocumentLinkProvid
});
}

private getDefinitionPosition(range: vscode.Range): vscode.Position {
const { start, end } = range;
if (end.isAfter(start)) {
const character = Math.max(start.character, end.character - 1);
return new vscode.Position(start.line, character);
}
return start;
}

public dispose(): void {
for (const timeout of this.refreshTimeouts.values()) {
clearTimeout(timeout);
Expand Down