mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-16 11:00:23 +00:00
commit
eeef833d5c
@ -26,31 +26,31 @@ function getCmd(idx)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
M.gotoTerminal = function(idx)
|
function find_terminal(idx)
|
||||||
local term_handle = terminals[idx]
|
local term_handle = terminals[idx]
|
||||||
|
if not term_handle or not vim.api.nvim_buf_is_valid(term_handle.buf_id) then
|
||||||
if not term_handle then
|
|
||||||
local buf_id, term_id = create_terminal()
|
local buf_id, term_id = create_terminal()
|
||||||
if buf_id == nil then
|
if buf_id == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
term_handle = {
|
term_handle = {
|
||||||
buf_id = buf_id,
|
buf_id = buf_id,
|
||||||
term_id = term_id
|
term_id = term_id
|
||||||
}
|
}
|
||||||
terminals[idx] = term_handle
|
terminals[idx] = term_handle
|
||||||
end
|
end
|
||||||
|
return term_handle
|
||||||
|
end
|
||||||
|
|
||||||
|
M.gotoTerminal = function(idx)
|
||||||
|
local term_handle = find_terminal(idx)
|
||||||
|
|
||||||
vim.api.nvim_set_current_buf(term_handle.buf_id)
|
vim.api.nvim_set_current_buf(term_handle.buf_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.sendCommand = function(idx, cmd)
|
M.sendCommand = function(idx, cmd)
|
||||||
local term_handle = terminals[idx]
|
local term_handle = find_terminal(idx)
|
||||||
|
|
||||||
if not term_handle then
|
|
||||||
M.gotoTerminal(idx)
|
|
||||||
term_handle = terminals[idx]
|
|
||||||
end
|
|
||||||
|
|
||||||
if type(cmd) == "number" then
|
if type(cmd) == "number" then
|
||||||
cmd = terminal_config.cmds[cmd]
|
cmd = terminal_config.cmds[cmd]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user