Skip to content
Open
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
4 changes: 2 additions & 2 deletions lua/floaterm/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local volt_redraw = require("volt").redraw
local M = {}

M.edit_name = function()
local row = utils.get_buf_on_cursor()
local row = utils.get_selected_term_index()

if row then
vim.ui.input({ prompt = "  Enter name: " }, function(input)
Expand Down Expand Up @@ -63,7 +63,7 @@ M.delete_term = function(buf)
local method = buf and "automatic" or "manual"

if not buf then
local i = utils.get_buf_on_cursor()
local i = utils.get_selected_term_index()
if i then
buf = state.terminals[i].buf
end
Expand Down
10 changes: 10 additions & 0 deletions lua/floaterm/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ M.get_term_by_key = function(tocompare, name)
end

M.get_buf_on_cursor = function()
local curwin = vim.api.nvim_get_current_win()
if curwin ~= state.sidewin then
return nil
end
local row = vim.api.nvim_win_get_cursor(0)[1]

if not state.terminals[row] then
Expand All @@ -126,6 +130,12 @@ M.get_buf_on_cursor = function()
return row
end

M.get_selected_term_index = function()
local row = M.get_buf_on_cursor()
local term = M.get_term_by_key(state.buf)[1]
return row or term
end

M.close_timers = function()
state.bar_redraw_timer:stop()
state.bar_redraw_timer:close()
Expand Down