From 6b6dcf8ff991c5ced02ba2a0138b27dacbfd2ae7 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 3 Oct 2024 15:32:01 +0100 Subject: [PATCH] Display add-on version in the displayAddons command (#2662) --- lib/ruby_lsp/server.rb | 2 +- test/server_test.rb | 4 +++- vscode/src/common.ts | 2 ++ vscode/src/rubyLsp.ts | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ruby_lsp/server.rb b/lib/ruby_lsp/server.rb index 1da67ff4d..353934daf 100644 --- a/lib/ruby_lsp/server.rb +++ b/lib/ruby_lsp/server.rb @@ -89,7 +89,7 @@ def process_message(message) id: message[:id], response: Addon.addons.map do |addon| - { name: addon.name, errored: addon.error? } + { name: addon.name, version: addon.version, errored: addon.error? } end, ), ) diff --git a/test/server_test.rb b/test/server_test.rb index 5779a312d..799ab3b47 100644 --- a/test/server_test.rb +++ b/test/server_test.rb @@ -461,9 +461,11 @@ def test_workspace_addons addons_info = @server.pop_response.response assert_equal("Foo", addons_info[0][:name]) + assert_equal("0.1.0", addons_info[0][:version]) refute(addons_info[0][:errored]) assert_equal("Bar", addons_info[1][:name]) + assert_equal("0.2.0", addons_info[1][:version]) assert(addons_info[1][:errored]) ensure RubyLsp::Addon.addons.clear @@ -722,7 +724,7 @@ def name def deactivate; end def version - "0.1.0" + "0.2.0" end end end diff --git a/vscode/src/common.ts b/vscode/src/common.ts index 3f688fd9e..0ac408dd9 100644 --- a/vscode/src/common.ts +++ b/vscode/src/common.ts @@ -39,6 +39,8 @@ export interface RubyInterface { export interface Addon { name: string; errored: boolean; + // Older versions of ruby-lsp don't return version for add-ons requests + version?: string; } export interface ClientInterface { diff --git a/vscode/src/rubyLsp.ts b/vscode/src/rubyLsp.ts index 0f3829e19..491666a63 100644 --- a/vscode/src/rubyLsp.ts +++ b/vscode/src/rubyLsp.ts @@ -286,7 +286,7 @@ export class RubyLsp { .map((addon) => { const icon = addon.errored ? "$(error)" : "$(pass)"; return { - label: `${icon} ${addon.name}`, + label: `${icon} ${addon.name} ${addon.version ? `v${addon.version}` : ""}`, }; });