-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Description
In some cases, when suggestions are accepted programmatically (like the super-tab behavior), the is_visible function incorrectly returns a truthy value.
Reproduction Path
-
Use the following configuration:
~/.config/nvim/init.lua
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) if vim.v.shell_error ~= 0 then vim.api.nvim_echo({ { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { out, "WarningMsg" }, { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() os.exit(1) end end vim.opt.rtp:prepend(lazypath) vim.g.mapleader = " " vim.g.maplocalleader = "\\" require("lazy").setup({ spec = { { { "zbirenbaum/copilot.lua", cmd = "Copilot", build = ":Copilot auth", event = "BufReadPost", opts = { suggestion = { auto_trigger = true, keymap = { accept = false, }, }, panel = { enabled = false }, }, }, }, }, install = { colorscheme = { "habamax" } }, checker = { enabled = true }, }) vim.keymap.set({ "i", "s" }, "<Tab>", function() local copilot = require("copilot.suggestion") vim.notify(string.format("is_visible() => %s", tostring(copilot.is_visible())), vim.log.levels.INFO) if copilot.is_visible() then copilot.accept() else vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Tab>", true, false, true), "n", false) end end) -
Use the following file:
~/test.ts
const test = () => { return new Promise((resolve) => { setTimeout(() => { resolve('done'); }); }); } -
Open the file at the 6th line in insert mode:
nvim +'normal 6Gw' +startinsert ~/test.ts
-
Press
<Tab>two or more times. -
Open diagnostic messages via
:messages
Expected Behavior
- Tabs are being inserted as many times as the corresponding key is pressed.
- The
is_visible()function returns a falsy value:is_visible() => nil is_visible() => nil
Actual Behavior
- There is only one tab inserted.
- The
is_visible()function returns a truthy value.is_visible() => nil is_visible() => 5
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels