ibhagwan / fzf-lua

Improved fzf.vim written in lua
MIT License
2.25k stars 147 forks source link

[BUG] Unicode `REPLACEMENT CHARACTER`(efbfbd) in Buffers #672

Closed icefed closed 7 months ago

icefed commented 1 year ago

Info

fzf-lua configuration ```lua require('fzf-lua').setup({ winopts = { height = 0.85, -- window height width = 0.85, -- window width preview = { horizontal = "right:50%", scrollbar = false, }, }, files = { prompt = "Files> ", rg_opts = "--color=never --files --follow -g '!.git'", fd_opts = "--color=never --type f --follow --exclude .git", }, grep = { prompt = "Rg> ", input_prompt = "Grep For> ", }, }) ```

Description

Sometimes it comes, sometimes it doesn't.

ibhagwan commented 1 year ago

I noticed that too with buffers, there’s a good chance this is an upstream bug.

ibhagwan commented 1 year ago

@icefed, I haven’t encountered this issue in months, I have a feeling this was upstream (this character isn’t anywhere in fzf-lua’s code), although I can’t pin point the exact issue it does seem fixed on my end.

If you find a semi consistent way of reproducing this issue please reopen and I’ll take another look.

nyngwang commented 1 year ago

I also encountered this one many times. I think it has something to do with the transparent/blend of the floating window:

  1. When the line under the current floating window that contains efbfbd matches a certain pattern, this just happened.
  2. It's probably not related to the input method being used, since we all in this thread have this problem.
  3. It's probably not related to the terminal emulator we used since I'm using Alacritty and I encountered this problem too.

But IIRC, some older version of fzf-lua doesn't have this problem.

ibhagwan commented 1 year ago

When the line under the current floating window that contains efbfbd matches a certain pattern, this just happened.

If that’s the case that would be an upstream bug, fzf-lua doesn’t use this character at all in the code, where would it appear from?

Can you reproduce this consistently and let me know the steps?

liangxianzhe commented 1 year ago

Hi @ibhagwan

I might have a consistent repro. I guess the issue is related to how brackets are parsed, but didn't get a chance to dig deep.

To repro, copy the below config to somewhere like ~/.config/bug-report/init.lua, then NVIM_APPNAME="bug-report" nvim, then press fk and you will see the issue.

Env: NVIM v0.10.0-dev-1884+ga05bbc60e-Homebrew, latest fzf-lua, macos, alacritty.

local map = vim.keymap.set

-- Install Lazy when first opening nvim. Use ':Lazy' to install/update plugins.
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "--single-branch",
    "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
  { "nvim-tree/nvim-web-devicons", config = true, }, -- File type icons
  {
    "ibhagwan/fzf-lua",                              -- Fuzzy search everything
    config = function()
      require('fzf-lua').setup({})
      require("fzf-lua").register_ui_select() -- Use fzf for vim.ui.select, such as code actions, etc
      local f = "f"
      local F = "F"

      map("n", f .. "<space>", require('fzf-lua').builtin, { desc = "[f] All fzf commands" })
      map("n", f .. "a", require("fzf-lua").tabs, { desc = "[f] Tabs" })
      map("n", f .. "b", require("fzf-lua").buffers, { desc = "[f] Buffesr" })
      map("n", f .. "c", require("fzf-lua").git_bcommits, { desc = "[f] Commits for current file" })
      map("n", F .. "C", require("fzf-lua").git_commits, { desc = "[f] Commits for repo" })
      map("n", f .. "d", require("fzf-lua").diagnostics_document, { desc = "[f] Diagnostics in buffer" })
      map("n", F .. "D", require("fzf-lua").diagnostics_workspace, { desc = "[f] Diagnostics in workplace" })
      map("n", f .. "e", require('fzf-lua').changes, { desc = "[f] Edits (change list)" })
      map("n", f .. "f", require('fzf-lua').files, { desc = "[f] Files in cwd" })
      map("n", F .. "F", require('fzf-lua').git_files, { desc = "[f] Files in repo" })
      map("n", f .. "g", require('fzf-lua').live_grep_glob, { desc = "[f] Grep" })
      map("n", F .. "G", require('fzf-lua').grep_project, { desc = "[f] Fuzzy search project" })
      map("n", f .. "h", require("fzf-lua").git_status, { desc = "[f] Hunks (git status)" })
      map("n", f .. "j", require('fzf-lua').jumps, { desc = "[f] Jumps" })
      map("n", f .. "k", function() require('fzf-lua').keymaps({ query = "[]" }) end, { desc = "[f] Keybindings" })
      map("n", f .. "l", require('fzf-lua').loclist, { desc = "[f] Loclist" })
      map("n", F .. "L", require('fzf-lua').loclist_stack, { desc = "[f] Loclist history" })
      map("n", f .. "o", function() require("fzf-lua").lsp_document_symbols({ symbol_fmt = false, symbol_style = 2 }) end,
        { desc = "[f] Symbols in buffer" })
      map("n", F .. "O", require("fzf-lua").lsp_workspace_symbols, { desc = "[f] Symbols in repo" })
      map("n", f .. "q", require('fzf-lua').quickfix, { desc = "[f] Quickfix" })
      map("n", F .. "Q", require('fzf-lua').quickfix_stack, { desc = "[f] Quickfix history" })
      map("n", f .. "r", function() require("fzf-lua").oldfiles({ cwd_only = true }) end,
        { desc = "[f] Recent files in cwd" })
      map("n", F .. "R", require("fzf-lua").oldfiles, { desc = "[f] Recent files" })
      map("n", f .. "t", require("fzf-lua").btags, { desc = "[f] Tags in buffer" })
      map("n", F .. "T", require("fzf-lua").tags, { desc = "[f] Tags in repo" })
      map("n", f .. "w", require('fzf-lua').grep_cword, { desc = "[f] Grep cursor word" })
      map("n", F .. "W", require('fzf-lua').grep_cWORD, { desc = "[f] Grep cursor WORD" })

      map("n", f .. ".", require("fzf-lua").resume, { desc = "[f] Continue last fzf session" })
      map("n", f .. ";", require('fzf-lua').commands, { desc = "[f] Commands" })
      map("n", F .. ":", require('fzf-lua').command_history, { desc = "[f] Command history" })
      map("n", f .. "'", require('fzf-lua').marks, { desc = "[f] Marks" })
      map("n", F .. "\"", require('fzf-lua').registers, { desc = "[f] Registers" })
      map("n", f .. "/", require('fzf-lua').search_history, { desc = "[f] Search history" })
      map("n", f .. "1", require('fzf-lua').help_tags, { desc = "[f] Help tags" })

      map("n", "z=", require("fzf-lua").spell_suggest, { desc = "[f] Spell suggestion" }) -- Override the default ":h z="
    end
  },
}

require("lazy").setup(plugins)
ibhagwan commented 1 year ago

@liangxianzhe, just tried with latest nightly and the provided init.lua and no success in repro: image

ibhagwan commented 1 year ago

@liangxianzhe, what version of fzf are you using btw?

liangxianzhe commented 1 year ago

0.42.0, which is latest. I noticed that it repros consistently on alacritty, but not on wezterm (though my full config, which has more key bindings, repros on wezterm too). If it doesn't repro for you, I will try debug on my side when I got some time.

liangxianzhe commented 1 year ago

New finding, it only repros for certain terminal window's size. Try zoom in and out a few times.

liangxianzhe commented 1 year ago

image

nyngwang commented 1 year ago

@liangxianzhe Hi, really thank you for creating the repo of the issue!

ibhagwan commented 1 year ago

New finding, it only repros for certain terminal window's size. Try zoom in and out a few times.

Ty @liangxianzhe, reopened the issue but unfortunately I still cannot reproduce this using both alacritty and fzf 0.42.

Also, given that fzf-lua doesn't draw anything when zooming in/out I stand by my initial analysis that this is an upstream issue.

My suggestions is we try to reproduce it in the shell and once we have decent repro steps open an issue upstream.

ibhagwan commented 1 year ago

Following the discussion in #791, @liangxianzhe identified this issue as https://github.com/neovim/neovim/issues/16245, it seems there is not much we can do from fzf-lua’s side without the upstream being fixed.

ibhagwan commented 7 months ago

FYI, the issue was resolved upstream in https://github.com/neovim/neovim/pull/27922.

Can anyone who had this easily reproduced try this out once the next nightly is released?

icefed commented 7 months ago

I've been using it for a few minutes, it looks like the problem is gone.

Open same session(nightly left):

image
ibhagwan commented 7 months ago

Ty for the update @icefed, I also feel confident this issue can be closed, ty everyone for your efforts troubleshooting this!