Comments (18)
I'm not sure I understand why a dedicated event is needed, won't flushing the desired state in the appropriate places be sufficient; like in #27950?
And for cmdpreview in particular, removing the redraw restriction is the way forward: #28510.
right before redraw
I was able to finally just queue the messages received in the
vim.ui_attach
callback and no longer need to do screen updates orredraws
during.
Care to elaborate on these? I deliberately did not look at noice's implementation and it's workarounds when working on the default ext UI(which I have postponed to work on for the time being) and instead aimed to resolve issues in the C core as I ran into them.
from neovim.
If I understand correctly now, the goal is to just make it all work without any new low-level API and where the lua callback is allowed to fully alter views during.
I mean this has been my goal, and so far I had not gotten the impression that there is something fundamentally wrong with that approach. If that goes against previous discussions/conclusions that is solely because I was oblivious to them. Is there a reference to those discussions?
from neovim.
@luukvbaal maybe you have some ideas?
With all your recent changes, I was able to finally just queue the messages received in the vim.ui_attach
callback and no longer need to do screen updates or redraws
during.
from neovim.
What does "trigger vim.ui_attach
" mean?
from neovim.
The last r
will send an ext_cmdline message with the new cmdline.
So in noice, I have the correct cmdline state, I just can't render it without my work-around
from neovim.
I'm confused. What does this have to do with SafeState
?
from neovim.
I meant that it (or a similar event) could be useful to allow ui updates at some points where it's currently not possible.
To be fair, I think I just found a better work-around specifically for cmdpreview
, since CmdlineChanged
is triggered right before that.
from neovim.
I'm not sure what #27950 achieves regarding my bug report?
And for cmdpreview in particular, removing the redraw restriction is the way forward: #28510.
That would be great
Care to elaborate on these?
Previously I queued messages in the ui_attach
callback, and only updated the views when in a blocking event. Like right before getchar, or when the cmdline is active. This was needed, since otherwise it can happen that Neovim blocks the main loop somewhere waiting for input and I wasn't able to render views. Other view updates happen async in batches in the main loop.
With some of your recent updates, a lot of those blocking
view updates I did inside the ui_attach
callback started giving E565
errors, so I could no longer properly update views when needed.
Now I just queue messages and never try updating the UI in the callback (and never trigger redraws either during).
What would I need to do to get my command line floating window to redraw properly after receiving an ext_cmdline
message using #27950?
from neovim.
fyi, how I currently solve the issue with cmdpreview
:
- in a
CmdlineChanged
callback I do: - with
ffi
setcmdpreview = false
- trigger a
redraw
- update the view (update/create buffers/windows)
- possibly trigger another redraw when needed
from neovim.
I'm not sure what #27950 achieves regarding my bug report?
This bug report or #20463? Like I mentioned in the last comment in that PR I think the change is sufficient to redraw updated cmdline state, did you try it out and experience otherwise?
Perhaps it's not obvious but cmdpreview
is temporarily set to false on each key press, so flushing before entering "cmdpreview" state again like in that PR indeed seems sufficient to "achieve something" regarding #20463.
from neovim.
Yes, I meant #20463 indeed.
I tried a couple of things with your PR:
- in the
vim.ui_attach
callback, when receiving acmdline
message, update the ui right away:- result was that the cmdline in my floating window was always one char too late as soon as you hit the second
/
in%s/foo/bar
(same as without your PR) - I also had a segfault, but I assume it's simply not a good idea to update the ui from the callback?
- result was that the cmdline in my floating window was always one char too late as soon as you hit the second
To be clear, I am getting all the cmdline
messages in time, but I'm just not able to create/update views due to redraw
not working when cmdpreview = false
from neovim.
in the vim.ui_attach callback, when receiving a cmdline message, update the ui right away:
This is what I've been doing and I think it should be allowed.
from neovim.
This is what I've been doing and I think it should be allowed
That would be really great, but at least before all your recent work, this segfaulted Neovim in a lot of different ways.
With your PR, I get a segfault after entering :%s
if I do a create/update windows in the ext_cmdline
callback.
Without your PR, it still doesn't work, but doesn't segfault.
from neovim.
I don't know if this is helpful but before #25629 I was able to render the cmdline having cmdpreview active without issues and no workaround, by just calling redraw in the callback after setting the line in a float. On master I do observe the lagging character issue and I can't update the float window at all after the second "/".
from neovim.
When I created Noice and hit some of the issues with the implementation of vim.ui_attach
, there were talks of maybe changing it so that callbacks would no longer be allowed to do redraws and where a new low-level API would be created to update/create windows.
Based on all the recent changes and new issues I hit with Noice, I mistakenly thought that was all in preparation of the above.
If I understand correctly now, the goal is to just make it all work without any new low-level API and where the lua callback is allowed to fully alter views during.
I also just tested #27950 again and it works great now. For Noice, this was probably the biggest issue with vim.ui_attach
till now. Looking forward to having this merged :)
Closing this issue, since it no longer applies.
from neovim.
Not really. Was mostly on matrix and a long time ago.
A lot of the underlying issues with redraw have been fixed since I released Noice. Things that also triggered segfaults unrelated to Noice.
To be clear, Noice only triggers redraws or updates/creates windows/buffers during the callback in very few cases, when I know for sure or it's possible for Neovim to block on input. Most of the time, a redraw is not needed and it was mostly those redraws that triggered segfaults. Noice also detects recursive redraws (or recursive vim.ui_attach callbacks).
The biggest new issue that popped up over the last couple of weeks were those E565
errors when I try to render stuff during the callback in those special cases. It seems that error is because of textlock
and triggered by NEovim treesitter code that does a redraw that triggers vim.ui_attach
events somehow. A similar situation happens with the inlay hints code.
I currently just queue updates in the callback during textlock
. To check if textlock
is active I have to use ffi. There's no builtin way right?
from neovim.
Sorry forgot to reply here @folke; short answer no I don't think there is a builtin way to check if textlock is active(other than pcall()
-> check error).
I do think we should try to avoid the issue you describe but I'm not sure what's the best way to resolve it.
The issue stems from nvim__redraw()
calling ui_flush()
in the decor provider callback which sets textlock. Maybe we can postpone flusing (to Lua callbacks?) when textlock is active.
from neovim.
postponing when active is probably a good approach here.
I currenty check if textlock is active with ffi and just queue the message, so receiving it later when textlock is not active would be better indeed
from neovim.
Related Issues (20)
- terminal COLUMNS/LINES not respected at startup, shows a small window (foot terminal) HOT 3
- nvim_set_hl does not work in (v0.9.4 / macOS v14.4.1) HOT 2
- glibc 2.29 not found error in v0.10.0+ HOT 1
- Conceal characters on cursor line except at cursor position HOT 2
- Please bring back `diff` in nvim windows binary HOT 3
- Neovim(nvim) doesn't resize to full terminal width upon opening HOT 3
- :Man softwrap (vim.g.man_hardwrap = 0) breaks table formatting HOT 1
- LSP client should be able to handle snippets that use $0 as a tabstop HOT 6
- `vim._with()` does not properly restore global-local options HOT 3
- signcolumn="yes" + cursorline results in line being visually indented backwards when going from unindented line to indented line HOT 2
- "autocmd BufRead" not working when "nvim a.lua" HOT 3
- Swapfile message (E325) doesn't use the default colorscheme HOT 1
- Incomplete Documentation for `vim.diagnostic.open_float` Options HOT 3
- Which plugins use :UpdateRemotePlugins ? HOT 4
- Cmake parser code is bad HOT 4
- Online doc strange highlights and offset display HOT 1
- Don't send "no information available" on `vim.lsp.buf.hover` if at least one attached server has information HOT 1
- Nightly release tsserver omnifunc doesn't complete partial identifier
- Nightly release: tsserver wrong autoimports with multiline imports
- Built-in LSP completion not filtering on label
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neovim.