Skip to content

Commit 72972ab

Browse files
authored
Merge pull request #630 from ckipp01/enableTestExplorer
refactor: include a message when Test Explorer is not set for select commands
2 parents 1a008b3 + df19be3 commit 72972ab

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lua/metals.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,11 +508,21 @@ M.toggle_setting = function(setting)
508508
end
509509

510510
M.select_test_suite = function()
511-
test_explorer.dap_select_test_suite()
511+
local config = conf.get_config_cache()
512+
if config and config.settings.metals.testUserInterface == "Test Explorer" then
513+
test_explorer.dap_select_test_suite()
514+
else
515+
log.error_and_show(messages.enable_test_explorer)
516+
end
512517
end
513518

514519
M.select_test_case = function()
515-
test_explorer.dap_select_test_case()
520+
local config = conf.get_config_cache()
521+
if config and config.settings.metals.testUserInterface == "Test Explorer" then
522+
test_explorer.dap_select_test_case()
523+
else
524+
log.error_and_show(messages.enable_test_explorer)
525+
end
516526
end
517527

518528
M.open_new_github_issue = function()

lua/metals/messages.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,7 @@ You recieved a null response for the tree view.
6363
If you're using Scala 3, this is expected as it's not support yet.
6464
If you're using Scala 2, please create an issue for this in nvim-metals.]]
6565

66+
M.enable_test_explorer = [[
67+
You can't use this command unless you have "Test Explorer" set as the value of testUserInterface in your config.
68+
You can read more about this in :h metals-nvim-dap.]]
6669
return M

0 commit comments

Comments
 (0)