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

Selecting prev/next in cmdline removes line range markers (<,>) #1092

Closed
2 tasks done
Davidyz opened this issue Jan 26, 2025 · 6 comments
Closed
2 tasks done

Selecting prev/next in cmdline removes line range markers (<,>) #1092

Davidyz opened this issue Jan 26, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@Davidyz
Copy link

Davidyz commented Jan 26, 2025

Make sure you have done the following

  • Updated to the latest version of blink.cmp
  • Searched for existing issues and documentation (try <C-k> on https://cmp.saghen.dev)

Bug Description

After visually selecting some lines and trying to type a command, for example :<,>s/foo/bar/ (<,> is automatically added by neovim as the selection range markers), when you just finished typing s and press <Up> (binded to "select_prev" when using enter preset), the completion menu will erase the <,> markers. The completion only works as intended if there is a space before s, for example: :<,> s/foo/bar/. Similar behaviour was observed when manually typing the line ranges, like :3,5s/foo/bar/ won't work, but :3,5 s/foo/bar/ will.

Relevant configuration

-- Run with `nvim -u repro.lua`

vim.env.LAZY_STDPATH = '.repro'
load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))()

---@diagnostic disable-next-line: missing-fields
require('lazy.minit').repro({
  spec = {
    {
      'saghen/blink.cmp',
      -- please test on `main` if possible
      -- otherwise, remove this line and set `version = '*'`
      build = 'cargo build --release',
      opts = {
        keymap = { cmdline = { preset='enter' }},
      },
    },
    {
      'neovim/nvim-lspconfig',
      opts = {
        servers = {
          lua_ls = {},
        },
      },
      config = function(_, opts)
        local lspconfig = require('lspconfig')
        for server, config in pairs(opts.servers) do
          -- passing config.capabilities to blink.cmp merges with the capabilities in your
          -- `opts[server].capabilities, if you've defined it
          config.capabilities = require('blink.cmp').get_lsp_capabilities()
          lspconfig[server].setup(config)
        end
      end,
    },
  },
})

neovim version

v0.10.3

blink.cmp version

main

@solidtesting
Copy link
Contributor

I've submitted a fix for this issue in PR #1155 .

@Davidyz
Copy link
Author

Davidyz commented Feb 5, 2025

Hi, thanks for the fix! It works for visual range selection (:'<,'>), but for line number ranges (:3,5) it doesn't seem to be working. Is it possible to fix this as well?

@ranjithshegde
Copy link

Thank you for working on the fix!!!
I think the parsing has to be extended for a general list of special characters as well. doing :echo &buf<completion_key> inserts the selection and removes &

@solidtesting
Copy link
Contributor

I've implemented a fix that preserves prefixes like &, visual ranges ('<,'>), and numeric ranges (3,5) during completion.

Tested with commands like :echo &buf<completion_key>, and it now behaves as expected.

Let me know if any further adjustments are needed!

@Davidyz
Copy link
Author

Davidyz commented Feb 6, 2025

@solidtesting Thanks, I can confirm the reported issues (both from me and @ranjithshegde) have been fixed. I'll keep this opened until the fix is merged.

@daUnknownCoder
Copy link

daUnknownCoder commented Feb 6, 2025

@Davidyz and @solidtesting i believe #1161 is also related but for the end part

@Saghen Saghen closed this as completed in f0aeac2 Feb 8, 2025
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

Successfully merging a pull request may close this issue.

4 participants