diff --git a/lua/rust-tools/cached_commands.lua b/lua/rust-tools/cached_commands.lua index d84b89e..1013ea2 100644 --- a/lua/rust-tools/cached_commands.lua +++ b/lua/rust-tools/cached_commands.lua @@ -6,12 +6,12 @@ local cache = { last_runnable = nil, } --- @param action -M.set_last_runnable = function(c, r) +-- @param action +M.set_last_runnable = function(choice, result) cache.last_runnable = { choice, result } end --- @param args +-- @param args M.set_last_debuggable = function(args) cache.last_debuggable = args end @@ -27,8 +27,8 @@ end M.execute_last_runnable = function() local action = cache.last_runnable - if action then - rt.runnables.run_command(action[0], action[1]) + if action then + rt.runnables.run_command(action[1], action[2]) else rt.runnables.runnables() end diff --git a/lua/rust-tools/runnables.lua b/lua/rust-tools/runnables.lua index 3cc51be..6e6fdfe 100644 --- a/lua/rust-tools/runnables.lua +++ b/lua/rust-tools/runnables.lua @@ -49,6 +49,7 @@ function M.run_command(choice, result) local command, args, cwd = getCommand(choice, result) opts.executor.execute_command(command, args, cwd) + rt.cached_commands.set_last_runnable(choice, result) end local function handler(_, result) @@ -57,11 +58,13 @@ local function handler(_, result) end -- get the choice from the user local options = get_options(result) - vim.ui.select(options, { prompt = "Runnables", kind = "rust-tools/runnables" }, function(_, choice) - M.run_command(choice, result) - - rt.cached_commands.set_last_runnable(choice, result) - end) + vim.ui.select( + options, + { prompt = "Runnables", kind = "rust-tools/runnables" }, + function(_, choice) + M.run_command(choice, result) + end + ) end -- Sends the request to rust-analyzer to get the runnables and handles them