-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Filetype is applied once for each line when redirecting command output #332
Comments
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
Just checked that this is still an issue. |
## Description Using `vim.b` variables seems slow for big tables. This PR improves performance of command output redirection (and possibly other places). From my tests this is an order of 20 sec -> 4 sec. Also, it looks like the current code sometimes assumes that `vim.b[buf].messages` is a list of buffers, while it is a list of message ids. I also changed it from a list to a set, because it's mostly used for random access. ## Related Issue(s) This helps in case described here: #332 (filetype is still applied many times, but from my recent benchmarks it seems that `vim.b.messages` had bigger impact).
Are you sure this is still a problem? The code that sets those options is wrapped in eventignore, so it should no longer trigger autocmds |
Ah, you're right. I used the original test, which was just checking that the filetype was being set, but if I create a However, I found another issue. I'm using perfanno.nvim which uses LuaJIT profiler ( So I added simple counter Is it possible to reimplement command redirection in such a way that it does not always replace the content of the whole buffer? I don't really understand the details of how this works, so I wonder if this is due to some limitation of how message redirection works or maybe there is some simple fix for that? |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.9.0-dev-784+g72f0c461a
Operating system/version
Arch Linux
Describe the bug
When using
noice.redirect
to display command output in a popup, it is very slow (e.g. over 1.2 seconds to display 50 lines on my system). After some debugging I found that it is due to constantly settingfiletype
for the buffer (View:render -> nui.nvim utils.set_buf_options). This option is being set on each displayed line, which in turn runs the following lines from ftplugin.vim, which is quite slow on my system and takes ~10ms for each call. Tested with:Steps To Reproduce
While in this repro it will not be slow because there are not many plugins in runtimepath, the following steps will show how many times the
filetype
option is being set:repro.lua
:nvim -u repro.lua
, then exitnui.patch
:cd ./.repro/plugins/nui.nvim/ && git apply ../../../nui.patch
nvim -u repro.lua
, type:TestCmd
and hit<m-cr>
:lua = _G.dbg
and hit<m-cr>
filetype
has been set for a buffer, which for one buffer should correspond to the number of message lines:Expected Behavior
Maybe this is an issue with my setup with quite a lot of plugins, or maybe I have some plugin that makes the call to
runtime!
very slow - I am not sure, I'll try to investigate more. But still I think it should be expected thatnoice
is not settingfiletype
on every output line.Repro
The text was updated successfully, but these errors were encountered: