neovide / neovide

No Nonsense Neovim Client in Rust
https://neovide.dev
MIT License
12.84k stars 520 forks source link

Inconsistent with terminal of vim.fn.screen* function #2569

Open xzbdmw opened 4 months ago

xzbdmw commented 4 months ago

Describe the bug vim.fn.screen* function only return statusline result

To Reproduce Steps to reproduce the behavior: repro.lua

vim.keymap.set("n", "gt", function()
    local col = vim.fn.screencol()
    local row = vim.fn.screenrow()
    local char = vim.fn.screenstring(row, col)
    -- __AUTO_GENERATED_PRINT_VAR_START__
    print([==[function#if#function char:]==], vim.inspect(char)) -- __AUTO_GENERATED_PRINT_VAR_END__
end)

move cursor to a char and type gt, the result is random string from statusline Expected behavior the result should be the same as cursor char Desktop (please complete the following information): macos 14.1 neovim 0.10 stable neovide 13.0

Please run neovide --log and paste the contents of the .log file created in the current directory here: neovide_rCURRENT.log.zip

Additional context Add any other context about the problem here.

fredizzimo commented 4 months ago

I think this might be related to this bug we reported to Neovim a while ago:

Does it work properly if you jump using the keyboard?

xzbdmw commented 4 months ago

Yes, mouse and keyboard is the same, and row and col is correct, only char is wrong

fredizzimo commented 4 months ago

I assume that you have tested this in the Neovim terminal app? It sounds strange that this is brokens, since Neovide does not manipulate any screen and cursor positions itself.

xzbdmw commented 4 months ago

Yes, kitty print correct cursor char

yasen-pavlov commented 4 months ago

Just wanted to chime in that I think I ran into this or a similar bug while I was trying to debug an issue I was having with the statuscol plugin. It uses vim.fn.screenstring to determine the sign in the folding column (link to relevant code) when you click on it and it's working in the terminal, but I was getting some weird behaviour in neovide.

What I managed to figure out so far is that for some reason vim.fn.screenstring always returns an empty string for me in neovide. I was able to reproduce this on a clean nvim config by running the following lua code :

for row = 1, 3, 1 do
    for column = 1, 10, 1 do
        local char = vim.fn.screenstring(row, column)
        print("row: " .. row .. " column: " .. column .. " char: " .. char)
    end
end

on this test file:

ABCDEFGHIJ
KLMNOPQRST
UVWXYZABCD

This is what I get in nvim running inside a terminal:

terminal

And this is what I got when I ran it inside neovide:

neovide

Starting neovide with --no-multigrid fixes this for me which leads me to believe that this behaviour is related to multigrid.

I have the same setup as @xzbdmw btw, MacOS Sonoma 14.5, nvim 0.10 stable and neovide 0.13.1, terminal is alacritty. I've had this issue since I started using the statuscol plugin (around neovide version 0.10 or 0.11) but I only very recently noticed that I can't reproduce it in the terminal.

fredizzimo commented 4 months ago

I reported a Neovim issue here: https://github.com/neovim/neovim/issues/29135