Skip to content

Commit

Permalink
Merge pull request #32 from harrylavell/pr/quick-pick-context
Browse files Browse the repository at this point in the history
Quick Pick Visible Context for Use With “when” Clauses
  • Loading branch information
tobias-z authored Nov 3, 2023
2 parents 05efdce + 4d5f322 commit abf49cb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ You are then able to jump to `editor 1` or `editor 2` from anywhere in your work
pick menu to pick between your global editors
- `VSCode Harpoon: Go to previous global harpoon editor (vscode-harpoon.gotoPreviousGlobalHarpoonEditor)` Jumps to the previous global editor which was last jumped from using harpoon.

### Available Contexts

- `VSCode Harpoon: Quick Pick Visible (vscode-harpoon.isQuickPick)` Adds context for determining whether harpoon's quick pick list is visible.


## Troubleshooting

If desired the extension does support jumping to already open editors in different split panes. However, for this to work you need to add a property to your settings.json:
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@
{
"command": "vscode-harpoon.gotoPreviousGlobalHarpoonEditor",
"title": "VSCode Harpoon: Go to previous global harpoon editor"
},
{
"command": "vscode-harpoon.isQuickPick",
"title": "VSCode Harpoon: Quick Pick Visible"
}
]
},
Expand Down
7 changes: 6 additions & 1 deletion src/commands/editor-quick-pick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default function createEditorQuickPickCommand(
) {
return async () => {
const quickPick = vscode.window.createQuickPick();
workspaceService.setQuickPickContext(true);

quickPick.items = activeProjectService.activeEditors.reduce((acc, editor, i) => {
if (editor.fileName !== "_") {
acc.push(toQuickPickItem(editor, i));
Expand Down Expand Up @@ -55,7 +57,10 @@ export default function createEditorQuickPickCommand(
}
});

quickPick.onDidHide(quickPick.dispose);
quickPick.onDidHide(() => {
workspaceService.setQuickPickContext(false);
quickPick.dispose();
});
quickPick.show();
};
}
Expand Down
4 changes: 4 additions & 0 deletions src/service/workspace-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export default class WorkspaceService {
});
}

public setQuickPickContext(isQuickPick: boolean) {
vscode.commands.executeCommand("setContext", "vscode-harpoon.isQuickPick", isQuickPick);
}

private async trackedPreviousEditor<T>(cb: () => Promise<T>): Promise<T> {
const activeEditor = vscode.window.activeTextEditor;
if (!activeEditor) {
Expand Down

0 comments on commit abf49cb

Please sign in to comment.