nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.98k stars 837 forks source link

Creating Telescope Picker From BufReadCmd Gives Unusable State #1846

Closed miversen33 closed 2 years ago

miversen33 commented 2 years ago

Description

When you attempt to create a picker from the BufReadCmd event, you end up in a state where your cursor is in the buffer under the floating window, and it doesn't appear you can force your way back into the telescope buffer. Additionally, it appears you cannot kill the floating window without completely killing your neovim session. Potentially related Issue 1804 Issue 1595 PR 1600

Neovim version

Tested on 0.7.0, 0.6.1, 0.6.0

NVIM v0.7.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az316-460

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
NVIM v0.6.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az87-780

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
NVIM v0.6.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az65-618

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

### Operating system and version

Ubuntu 20.04

### checkhealth telescope

```markdown
telescope: require("telescope.health").check()
========================================================================
## Checking for required plugins
│ - OK: plenary installed.
│ - OK: nvim-treesitter installed.

## Checking external dependencies
│ - OK: rg: found ripgrep 11.0.2
│ - OK: fd: found fd 7.4.0

## ===== Installed extensions =====

## Telescope Extension: `file_browser`
│ - INFO: No healthcheck provided

## Telescope Extension: `fzf`
│ - INFO: No healthcheck provided

## Telescope Extension: `live_grep_raw`
│ - INFO: No healthcheck provided

Steps to reproduce

Open your preferred neovim version with the below test configuration and some file

$ /usr/bin/nvim -u minimal.lua ~/somefile.txt

Expected behavior

I would expect the floating window to load, though there may be some shenanigans with how the floating window is created within the startup lifecycle of vim

Actual behavior

It seems as if the floating window is created and the focus is shifted to the underlying buffer that was created (likely after the floating window is created). Its possible that this is a neovim issue and not a telescope issue, I am unsure.

Minimal config

-- minimal.lua
require('packer').startup(function(use)
    use 'nvim-telescope/telescope.nvim' -- Fuzzy Finder
    if packer_bootstrap then
        require('packer').sync()
    end
end)

_G.test_scope = function()
    print("Hello world!")
end

vim.api.nvim_command('augroup testing')
vim.api.nvim_command('augroup END')

vim.api.nvim_command('autocmd testing BufReadCmd * lua ' .. [[
    local m = function()
        local opts = {};
        require('telescope.pickers').new(opts, {
        prompt_title = "colors",
        finder = require('telescope.finders').new_table {
            results = { "red", "green", "blue" }
        },
        sorter = require('telescope.config').values.generic_sorter(opts),
        }):find();
    end
    m()
]])
Conni2461 commented 2 years ago

what you could do is, you could schedule it. So m() -> vim.schedule(m) seems to work for me.

Conni2461 commented 2 years ago

Is this still relevant ?

miversen33 commented 2 years ago

Is this still relevant ?

I think wrapping the call in schedule is a viable solution (though it might be worth including something along those lines in the documentation for situations where a dev tries to open Telescope before the UI is available).

Feel free to close this out :)

Conni2461 commented 2 years ago

An Issue is some form of documentation :laughing: