Closed rhcher closed 2 years ago
can't reproduce. need mini config.
should fix now.
The bug still exists for me, but I can't reproduce it with mini config, so it is related to my config, I will look into it tomorrow.
--- a/lua/ufo/model/buffer.lua
+++ b/lua/ufo/model/buffer.lua
@@ -172,6 +172,9 @@ function Buffer:lines(lnum, endLnum)
self._q = {}
end
local hunks, cnt = self:handleChanged()
+ if self._lineCount < lnum then
+ require('ufo.lib.log').error(self._lineCount, lnum, debug.traceback('?????'))
+ end
assert(self._lineCount >= lnum, 'index out of bounds')
endLnum = endLnum and endLnum or lnum
if endLnum < 0 then
tail -f ~/.cache/nvim/ufo.log
may help.
The bug still exist for me, but I can't reproduce with mini config, so it related my personal config, I will look into tomorrow.
Keep us posted, this issue is happening to me also.
The bug still exist for me, but I can't reproduce with mini config, so it related my personal config, I will look into tomorrow.
Keep us posted, this issues is happening to me also.
More info is better.
--- a/lua/ufo/model/buffer.lua +++ b/lua/ufo/model/buffer.lua @@ -172,6 +172,9 @@ function Buffer:lines(lnum, endLnum) self._q = {} end local hunks, cnt = self:handleChanged() + if self._lineCount < lnum then + require('ufo.lib.log').error(self._lineCount, lnum, debug.traceback('?????')) + end assert(self._lineCount >= lnum, 'index out of bounds') endLnum = endLnum and endLnum or lnum if endLnum < 0 then
tail -f ~/.cache/nvim/ufo.log
may help.The bug still exist for me, but I can't reproduce with mini config, so it related my personal config, I will look into tomorrow.
Keep us posted, this issues is happening to me also.
More info is better.
Sorry, was looking into the log but seems like that file is missing for me. It doesn't happen every time. If I open and close Neovim chances are it will work or not.
Sorry not giving more info, let me look into it with a minimal config.
accord my test, it because 6c5b905f1dad08b4b2de5be1458a9ddcbb9e4325 , I just reuse vim.api.nvim_buf_get_lines and bug is gone.
It's weird. Could you add the above debug snippet and provide the log?
I can provide a log, but I still can't reproduce with mini config, so I can only provide debug log with my config, is it make sense?
Yes, please provide the actual line count for the buffer. self._lineCount
may get wrong.
[22-07-14 13:39:41] [ERROR] buffer.lua:173 : 1 172 ?????
stack traceback:
...site/pack/packer/start/nvim-ufo/lua/ufo/model/buffer.lua:173: in function 'lines'
...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/main.lua:124: in function <...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/main.lua:120>
[22-07-14 13:39:41] [ERROR] buffer.lua:173 : 1 172 ?????
stack traceback:
...site/pack/packer/start/nvim-ufo/lua/ufo/model/buffer.lua:173: in function 'lines'
...im/site/pack/packer/start/nvim-ufo/lua/ufo/decorator.lua:88: in function 'winCall'
...im/site/pack/packer/start/nvim-ufo/lua/ufo/decorator.lua:68: in function <...im/site/pack/packer/start/nvim-ufo/lua/ufo/decorator.lua:58>
[22-07-14 13:39:42] [ERROR] buffer.lua:173 : 1 172 ?????
stack traceback:
...site/pack/packer/start/nvim-ufo/lua/ufo/model/buffer.lua:173: in function 'lines'
...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/main.lua:124: in function <...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/main.lua:120>
[22-07-14 13:39:42] [ERROR] buffer.lua:173 : 1 172 ?????
stack traceback:
...site/pack/packer/start/nvim-ufo/lua/ufo/model/buffer.lua:173: in function 'lines'
...im/site/pack/packer/start/nvim-ufo/lua/ufo/decorator.lua:88: in function 'winCall'
...im/site/pack/packer/start/nvim-ufo/lua/ufo/decorator.lua:68: in function <...im/site/pack/packer/start/nvim-ufo/lua/ufo/decorator.lua:58>
buffer.lua have 200 lines
Please update the code, maybe the first buffer attached issue.
lua =require'ufo.bufmanager'.buffers[1].attached
should be true
after the new commiet.
Now it works like a charm! Thanks for your work
Encounter this issue again, here is the output of :lua =require'ufo.bufmanager'.buffers
{
[3] = {
_changedtick = 1,
_lines = { false },
attached = true,
bt = "",
bufnr = 3,
ft = "lua",
<metatable> = <1>{
__index = <table 1>,
attach = <function 1>,
buftype = <function 2>,
buildMissingHunk = <function 3>,
changedtick = <function 4>,
dispose = <function 5>,
filetype = <function 6>,
handleLinesChanged = <function 7>,
lineCount = <function 8>,
lines = <function 9>,
new = <function 10>,
reload = <function 11>,
sliceLines = <function 12>
}
}
}
Seems the bufnr may be any value.
Encounter this issue again, here is the output of
:lua =require'ufo.bufmanager'.buffers
{ [3] = { _changedtick = 1, _lines = { false }, attached = true, bt = "", bufnr = 3, ft = "lua", <metatable> = <1>{ __index = <table 1>, attach = <function 1>, buftype = <function 2>, buildMissingHunk = <function 3>, changedtick = <function 4>, dispose = <function 5>, filetype = <function 6>, handleLinesChanged = <function 7>, lineCount = <function 8>, lines = <function 9>, new = <function 10>, reload = <function 11>, sliceLines = <function 12> } } }
Seems the bufnr may be any value.
buffer content? how to reproduce it?
Buffer content. Currently no minimal vimrc as it seems conflict with other plugins. Any other debug instructions?
local M = {
_diagnostics_active = true,
}
local Log = require "core.log"
function M.root_dir(fname)
return require("lspconfig.util").root_pattern(unpack(myvim.root_markers))(fname) or vim.fn.getcwd()
end
function M.lsp_config(server_name, automatic_servers_installation)
automatic_servers_installation = automatic_servers_installation or false
local lsp_installer_servers = require "nvim-lsp-installer.servers"
local server_available, requested_server = lsp_installer_servers.get_server(server_name)
if server_available then
requested_server:on_ready(function()
local opts = { root_dir = M.root_dir }
requested_server:setup(opts)
end)
if (not requested_server:is_installed()) and automatic_servers_installation then
requested_server:install()
end
else
Log:info(server_name .. " not available")
end
end
function M.toggle_diagnostics()
if M._diagnostics_active then
vim.diagnostic.disable(0)
M._diagnostics_active = false
else
vim.diagnostic.enable(0)
M._diagnostics_active = true
end
end
return M
Currently no minimal vimrc as it seems conflict with other plugins.
Find them out and reproduce the issue. Otherwise, even if I want to help you, there is nothing I can do.
Problem fixed by removing lazy load.
Problem fixed by removing lazy load.
Did you load ufo when there are multiple tabpages? And the buffers out of bounds are in non-current tagepage?
I have only one tabpage. Some context
editor["kevinhwang91/nvim-ufo"] = {
-- NOTE(meijieru): cause problem.
-- event = { "BufReadPre" },
requires = "kevinhwang91/promise-async",
config = conf.ufo,
disable = not myvim.plugins.ufo.active,
}
Lol, use BufRead
instead. BufReadPre
is buggy for buffers. Like nvim_buf_line_count
always return 1.
Using BufRead
solves the problem. Thx!
With lazy.nvim, BufRead
is not working for me, I had to use event = "VeryLazy"
Lol, use
BufRead
instead.BufReadPre
is buggy for buffers. Likenvim_buf_line_count
always return 1.
this worked for me as well.
Neovim version (nvim -v | head -n1)
NVIM v0.8.0-dev+608-g778541067-dirty
Operating system/version
wsl2 Arch
How to reproduce the issue
za
to trigger a foldnote thant it must use lua language server to reproduce.
Expected behavior
Get correct folded result
Actual behavior
There is a 0 with some buf info in screen.![image](https://user-images.githubusercontent.com/50723480/178777193-a15773a3-84a6-4146-8279-df156e6e1e9c.png)