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

to_fuzzy_refine does not work with <C-Space> mapping in Powershell in Windows Terminal #2646

Closed
kmoschcau opened this issue Aug 10, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@kmoschcau
Copy link

kmoschcau commented Aug 10, 2023

Description

So I know this sounds weird, but for some reason to_fuzzy_refine does no longer seem to work with the <C-Space> mapping. I can't say when exactly this started, I only really noticed it recently.

When I run the live_grep builtin, <C-Space> no longer does anything. It is still listed in the output of :imap <C-Space> when in the live_grep input buffer. There is no other key mapping listed. It does also still show up in the telescope help.

At first I tried to explicitly define it in my config like so:

local actions = require "telescope.actions"
require("telescope").setup {
  pickers = {
    live_grep = {
      mappings = {
        i = {
          ["<C-Space>"] = actions.to_fuzzy_refine,
        },
      },
    },
  },
}

This also does not do anything. The mapping still shows up in :imap output and help.

Then I just had a hunch and simply changed the mapping to <C-f> and suddenly the fuzzy refine works. Both mappings show up in :imap output, pointing at the same line in the plugin's code. They also show up in the telescope help.

Oh and <C-Space> works in general. The cmp plugin for example uses it, so it shouldn't be the terminal emulator swallowing it or something like that.

Addendum

It turns out this only happens with the neovim instance running on Windows in Powershell 7.3.6 in Windows Terminal. The neovim instance running in WSL2/fish 3.6.1 in the same Windows Terminal does not exhibit this behavior, even with the same minimal config.
Version of the working neovim instance:

NVIM v0.10.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Addendum 2

Turns out <C-Space> does not work in the windows instance at all. I must have misremembered. So it might just be that this is caused by either the older neovim version or Powershell

Neovim version

NVIM v0.9.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe /MD /Zi /O2 /Ob1  -W3 -wd4311 -wd4146 -DUNIT_TESTING -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_WIN32_WINNT=0x0602 -DMSWIN -DINCLUDE_GENERATED_DECLARATIONS -ID:/a/neovim/neovim/.deps/usr/include/luajit-2.1 -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/build/src/nvim/auto -ID:/a/neovim/neovim/build/include -ID:/a/neovim/neovim/build/cmake.config -ID:/a/neovim/neovim/src -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include

   system vimrc file: "$VIM\sysinit.vim"
  fall-back for $VIM: "C:/Program Files (x86)/nvim/share/nvim"

Operating system and version

Windows 11 (22H2 (OS Build 22621.2134))

Telescope version / branch / rev

branch 0.1.x (776b509)

checkhealth telescope

==============================================================================
telescope: require("telescope.health").check()

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 13.0.0
- OK fd: found fd 8.7.0

===== Installed extensions ===== ~

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Telescope Extension: `notify` ~
- No healthcheck provided

Steps to reproduce

  1. nvim -nu minimal.lua
  2. press Ctrl+/ (<C-_>)
  3. press <C-Space> -> nothing happens
  4. press <C-f> -> fuzzy refine is activated

Expected behavior

Fuzzy refine activates on <C-Space>.

Actual behavior

Fuzzy refine does not activate on <C-Space>, but does for other key mappings.

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  require('telescope').setup {
    pickers = {
      live_grep = {
        mappings = {
          i = {
            ["<C-f>"] = require("telescope.actions").to_fuzzy_refine,
          },
        },
      },
    },
  }
  require('telescope').load_extension('fzf')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]

vim.keymap.set("n", "<C-_>", require("telescope.builtin").live_grep, {
  desc = "Open telescope live grep search.",
  silent = true,
})
@kmoschcau kmoschcau added the bug Something isn't working label Aug 10, 2023
@kmoschcau
Copy link
Author

OK I'm just going to leave this here for posterity. I was just able to update the windows neovim instance to this:

NVIM v0.10.0-dev-798+g72e619ca9
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Turns out even with this newer version the <C-Space> key mapping in general does not work at all in Powershell for some reason.

@GitMurf
Copy link

GitMurf commented Jan 20, 2024

@kmoschcau fyi this thread explains a bit about why c-space doesn't work on Windows. It has taken me down many rabbit holes in the past given so many plugins use the c-space keymap: neovim/neovim#8435

@GitMurf
Copy link

GitMurf commented Jan 20, 2024

ok @kmoschcau more updates! You may already be aware as I found it by following a few of your gh issues comments ;) but the c-space issue is a bug in the core microsoft windows terminal and all the details can be found here: microsoft/terminal#15939

Here is the PR with the fix which has NOT landed in the core terminal release yet on Windows: microsoft/terminal#16298

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants