Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display output channel when addons are clicked #2850

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
28 changes: 18 additions & 10 deletions vscode/src/rubyLsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,24 +287,32 @@ export class RubyLsp {
}

const options: vscode.QuickPickItem[] = client.addons
.sort((addon) => {
// Display errored addons last
if (addon.errored) {
return 1;
}

return -1;
})
.sort((addon) => (addon.errored ? 1 : -1))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sort callback needs to handle the case where both addons have the same error state. The current implementation only looks at a single addon at a time, which isn't sufficient for a proper sort. Here's the correct implementation:

.sort((a, b) => (a.errored === b.errored ? 0 : a.errored ? 1 : -1))

This ensures stable sorting by comparing both addons and maintaining their relative positions when they share the same error state.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sort callback needs to handle the case where both addons have the same error state. The current implementation only looks at a single addon at a time, which isn't sufficient for a proper sort. Here's the correct implementation:

.sort((a, b) => (a.errored === b.errored ? 0 : a.errored ? 1 : -1))

This ensures stable sorting by comparing both addons and maintaining their relative positions when they share the same error state.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

.map((addon) => {
const icon = addon.errored ? "$(error)" : "$(pass)";
return {
label: `${icon} ${addon.name} ${addon.version ? `v${addon.version}` : ""}`,
};
});

await vscode.window.showQuickPick(options, {
placeHolder: "Addons (readonly)",
const quickPick = vscode.window.createQuickPick();
quickPick.items = options;
quickPick.placeholder = "Addons (click to view output)";

quickPick.onDidAccept(() => {
const selected = quickPick.selectedItems[0];
// Ideally, we should display information that's specific to the selected addon
if (selected) {
this.currentActiveWorkspace()?.outputChannel.show();
}
quickPick.hide();
});

quickPick.onDidHide(() => {
quickPick.dispose();
});

quickPick.show();
}),
vscode.commands.registerCommand(Command.ToggleFeatures, async () => {
// Extract feature descriptions from our package.json
Expand Down
Loading