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

Commit

Permalink
Merge pull request #75 from CsCherrYY/cs-adopt-location
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken authored May 3, 2022
2 parents 430750f + 9e05feb commit 88c7b06
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ export function register(tree: SymbolsTree, context: vscode.ExtensionContext): v
}
};

function setTypeHierarchyDirection(value: TypeHierarchyDirection, anchor: TypeItem | unknown) {
function setTypeHierarchyDirection(value: TypeHierarchyDirection, anchor: TypeItem | vscode.Location | unknown) {
direction.value = value;

let newInput: TypesTreeInput | undefined;
const oldInput = tree.getInput();
if (anchor instanceof TypeItem) {
newInput = new TypesTreeInput(new vscode.Location(anchor.item.uri, anchor.item.selectionRange.start), direction.value);
} else if (anchor instanceof vscode.Location) {
newInput = new TypesTreeInput(anchor, direction.value);
} else if (oldInput instanceof TypesTreeInput) {
newInput = new TypesTreeInput(oldInput.location, direction.value);
}
Expand All @@ -36,8 +38,8 @@ export function register(tree: SymbolsTree, context: vscode.ExtensionContext): v

context.subscriptions.push(
vscode.commands.registerCommand('references-view.showTypeHierarchy', showTypeHierarchy),
vscode.commands.registerCommand('references-view.showSupertypes', (item: TypeItem | unknown) => setTypeHierarchyDirection(TypeHierarchyDirection.Supertypes, item)),
vscode.commands.registerCommand('references-view.showSubtypes', (item: TypeItem | unknown) => setTypeHierarchyDirection(TypeHierarchyDirection.Subtypes, item)),
vscode.commands.registerCommand('references-view.showSupertypes', (item: TypeItem | vscode.Location | unknown) => setTypeHierarchyDirection(TypeHierarchyDirection.Supertypes, item)),
vscode.commands.registerCommand('references-view.showSubtypes', (item: TypeItem | vscode.Location | unknown) => setTypeHierarchyDirection(TypeHierarchyDirection.Subtypes, item)),
vscode.commands.registerCommand('references-view.removeTypeItem', removeTypeItem)
);
}
Expand Down

0 comments on commit 88c7b06

Please sign in to comment.