maybe?
This commit is contained in:
@@ -8,16 +8,13 @@ function M.float_terminal(cmd, opts)
|
|||||||
local row = math.floor((vim.o.lines - height) / 2)
|
local row = math.floor((vim.o.lines - height) / 2)
|
||||||
local col = math.floor((vim.o.columns - width) / 2)
|
local col = math.floor((vim.o.columns - width) / 2)
|
||||||
|
|
||||||
-- FIX: 'buf' should be the first argument, not inside the options table.
|
-- FIX 1: 'buf' is the first argument, not in the options table.
|
||||||
vim.api.nvim_open_win(buf, true, {
|
vim.api.nvim_open_win(buf, true, {
|
||||||
style = "minimal", relative = "editor",
|
style = "minimal", relative = "editor",
|
||||||
width = width, height = height, row = row, col = col,
|
width = width, height = height, row = row, col = col,
|
||||||
border = opts.border or "rounded",
|
border = opts.border or "rounded",
|
||||||
-- The key 'buf' was removed from here.
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- --- START MODIFICATION ---
|
|
||||||
|
|
||||||
-- Format the command as a string for display
|
-- Format the command as a string for display
|
||||||
local cmd_display
|
local cmd_display
|
||||||
if type(cmd) == 'table' then
|
if type(cmd) == 'table' then
|
||||||
@@ -32,11 +29,13 @@ function M.float_terminal(cmd, opts)
|
|||||||
"", -- Add an empty line for separation
|
"", -- Add an empty line for separation
|
||||||
})
|
})
|
||||||
|
|
||||||
-- --- END MODIFICATION ---
|
-- FIX 2: Clear the 'modified' flag so termopen can proceed.
|
||||||
|
vim.api.nvim_buf_set_option(buf, 'modified', false)
|
||||||
|
|
||||||
local function scroll_bottom()
|
local function scroll_bottom()
|
||||||
local win = vim.api.nvim_get_current_win()
|
local win = vim.api.nvim_get_current_win()
|
||||||
vim.api.nvim_win_set_cursor(win, {vim.api.nvim_buf_line_count(0), 0})
|
-- Get the line count of the current buffer (which should be 'buf' at this point)
|
||||||
|
vim.api.nvim_win_set_cursor(win, {vim.api.nvim_buf_line_count(buf), 0})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- We need to ensure the terminal starts in the correct buffer
|
-- We need to ensure the terminal starts in the correct buffer
|
||||||
@@ -44,6 +43,8 @@ function M.float_terminal(cmd, opts)
|
|||||||
|
|
||||||
local job = vim.fn.termopen(cmd, {
|
local job = vim.fn.termopen(cmd, {
|
||||||
cwd = opts.cwd,
|
cwd = opts.cwd,
|
||||||
|
-- NOTE: You may want to use vim.api.nvim_win_set_cursor on the specific win handle
|
||||||
|
-- instead of getting the current win inside the callback for more reliability.
|
||||||
on_stdout = function(...) scroll_bottom() end,
|
on_stdout = function(...) scroll_bottom() end,
|
||||||
on_stderr = function(...) scroll_bottom() end,
|
on_stderr = function(...) scroll_bottom() end,
|
||||||
on_exit = function(_, code, _)
|
on_exit = function(_, code, _)
|
||||||
|
|||||||
Reference in New Issue
Block a user