Skip to content
Merged
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
Copy link
Member

Choose a reason for hiding this comment

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

If we provide an API in the server that tags logs with the add-on name, then you might be able to reveal the output channel with a filter applied, so that you only see the output related to that add-on.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that will be great too 👍

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