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

Show that server is running on degraded mode #2800

Merged
merged 1 commit into from
Oct 30, 2024
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
1 change: 1 addition & 0 deletions lib/ruby_lsp/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def run_initialize(message)
version: VERSION,
},
formatter: @global_state.formatter,
degraded_mode: !!(@install_error || @setup_error),
}

send_message(Result.new(id: message[:id], response: response))
Expand Down
6 changes: 6 additions & 0 deletions vscode/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export default class Client extends LanguageClient implements ClientInterface {
public readonly ruby: Ruby;
public serverVersion?: string;
public addons?: Addon[];
public degraded = false;
private readonly workingDirectory: string;
private readonly telemetry: vscode.TelemetryLogger;
private readonly createTestItems: (response: CodeLens[]) => void;
Expand Down Expand Up @@ -355,6 +356,11 @@ export default class Client extends LanguageClient implements ClientInterface {
async afterStart() {
this.#formatter = this.initializeResult?.formatter;
this.serverVersion = this.initializeResult?.serverInfo?.version;

if (this.initializeResult?.degraded_mode) {
this.degraded = this.initializeResult?.degraded_mode;
}

await this.fetchAddons();
}

Expand Down
1 change: 1 addition & 0 deletions vscode/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface ClientInterface {
formatter: string;
addons?: Addon[];
serverVersion?: string;
degraded: boolean;
sendRequest<T>(
method: string,
param: any,
Expand Down
9 changes: 8 additions & 1 deletion vscode/src/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ export class ServerStatus extends StatusItem {
this.item.text = workspace.lspClient.serverVersion
? `Ruby LSP v${workspace.lspClient.serverVersion}: Running`
: "Ruby LSP: Running";

if (workspace.lspClient.degraded) {
this.item.text += " (degraded)";
this.item.severity = vscode.LanguageStatusSeverity.Warning;
} else {
this.item.severity = vscode.LanguageStatusSeverity.Information;
}

this.item.command!.arguments = [STARTED_SERVER_OPTIONS];
this.item.severity = vscode.LanguageStatusSeverity.Information;
break;
}
case State.Starting: {
Expand Down
19 changes: 19 additions & 0 deletions vscode/src/test/suite/status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ suite("StatusItems", () => {
formatter: "none",
serverVersion: "1.0.0",
sendRequest: <T>() => Promise.resolve([] as T),
degraded: false,
},
error: false,
};
Expand Down Expand Up @@ -78,6 +79,7 @@ suite("StatusItems", () => {
formatter: "none",
serverVersion: "1.0.0",
sendRequest: <T>() => Promise.resolve([] as T),
degraded: false,
},
error: false,
};
Expand Down Expand Up @@ -128,6 +130,19 @@ suite("StatusItems", () => {
);
assert.strictEqual(status.item.name, "Ruby LSP Server Status");
});

test("Refresh when server is in degraded mode", () => {
workspace.lspClient!.degraded = true;
status.refresh(workspace);
assert.strictEqual(
status.item.text,
"Ruby LSP v1.0.0: Running (degraded)",
);
assert.strictEqual(
status.item.severity,
vscode.LanguageStatusSeverity.Warning,
);
});
});

suite("ExperimentalFeaturesStatus", () => {
Expand All @@ -141,6 +156,7 @@ suite("StatusItems", () => {
formatter,
serverVersion: "1.0.0",
sendRequest: <T>() => Promise.resolve([] as T),
degraded: false,
},
error: false,
};
Expand Down Expand Up @@ -170,6 +186,7 @@ suite("StatusItems", () => {
formatter: "none",
serverVersion: "1.0.0",
sendRequest: <T>() => Promise.resolve([] as T),
degraded: false,
},
error: false,
};
Expand Down Expand Up @@ -258,6 +275,7 @@ suite("StatusItems", () => {
state: State.Running,
formatter: "auto",
serverVersion: "1.0.0",
degraded: false,
sendRequest: <T>() => Promise.resolve([] as T),
},
error: false,
Expand All @@ -283,6 +301,7 @@ suite("StatusItems", () => {
addons: undefined,
state: State.Running,
formatter: "auto",
degraded: false,
serverVersion: "1.0.0",
sendRequest: <T>() => Promise.resolve([] as T),
},
Expand Down
Loading