Skip to content
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

redraw doesn't update the UI during substitute #20463

Closed
Tracked by #6 ...
folke opened this issue Oct 3, 2022 · 6 comments · Fixed by #27950
Closed
Tracked by #6 ...

redraw doesn't update the UI during substitute #20463

folke opened this issue Oct 3, 2022 · 6 comments · Fixed by #27950
Assignees
Labels
bug issues reporting wrong behavior ui

Comments

@folke
Copy link
Member

folke commented Oct 3, 2022

When using vim.ui_attach with ext_cmdline, :redraw doesn't update the ui during substitute

@folke folke added the bug issues reporting wrong behavior label Oct 3, 2022
@clason clason added ui lua stdlib ui-extensibility UI extensibility, events, protocol, externalized UI labels Oct 3, 2022
@folke folke changed the title ext_cmdline stops sending cmdline_pos updates during substitute redraw doesn't update the UI during substitute Oct 24, 2022
@folke
Copy link
Member Author

folke commented Oct 24, 2022

The following hack seems to work:

  if vim.api.nvim_get_mode().mode == "c" and vim.fn.getcmdline():find("s/") then
    -- HACK: this will trigger redraw during substitue
    vim.api.nvim_input("<space><bs>")
  end

@zeertzjq
Copy link
Member

Hmm, this seem to be intentional from #9783

@zeertzjq zeertzjq removed lua stdlib ui-extensibility UI extensibility, events, protocol, externalized UI labels Oct 27, 2022
@folke
Copy link
Member Author

folke commented Oct 27, 2022

Damn, you're right. Any idea how my hack works?

Would there be a better way to force a redraw that doesnt enter characters?

@folke
Copy link
Member Author

folke commented Oct 27, 2022

The cmdline_show events also do come in before the redraw lock, but it seems the cmdline_pos events come in after the redraw lock.

Maybe it can be fixes by also sending the cmdline_pos events before the redraw lock?

@folke
Copy link
Member Author

folke commented Oct 27, 2022

So, that's why my hack works. I simply get a new cmdline_show event

@folke
Copy link
Member Author

folke commented Nov 16, 2022

I was able to fix this for Noice by calling update_screen() with ffi

  local ffi = require("noice.util.ffi")
  if ffi.cmdpreview then
    -- HACK: this will trigger redraw during substitute and cmdpreview,
    -- but when moving the cursor, the screen will be cleared until
    -- a new character is entered
    ffi.update_screen()
  end

I only call that code during substitute and when the cmdline cursor is not at the end of the cmdline, to prevent flickering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior ui
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants