Skip to content

Commit 5b9ff2e

Browse files
committed
fix(treesitter): preserve prompt cursor position
1 parent 3ae7c82 commit 5b9ff2e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lua/astrocore/treesitter.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,17 @@ function M.disable(bufnr)
322322
textobject_mappings[bufnr] = nil
323323
return
324324
end
325+
local was_enabled = enabled[bufnr] == true
325326
enabled[bufnr] = false
326327
pcall(vim.treesitter.stop, bufnr)
327328
highlights[bufnr] = nil
328329
restore_owned_indentexpr(bufnr)
329330
clear_textobject_mappings(bufnr)
330-
vim.schedule(function()
331-
if vim.api.nvim_get_current_buf() == bufnr and vim.bo[bufnr].buftype ~= "terminal" then vim.cmd "normal! zx" end
332-
end)
331+
if was_enabled then
332+
vim.schedule(function()
333+
if vim.api.nvim_get_current_buf() == bufnr and vim.bo[bufnr].buftype ~= "terminal" then vim.cmd "normal! zx" end
334+
end)
335+
end
333336
end
334337

335338
--- Check if treesitter features in buffer

0 commit comments

Comments
 (0)