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

builtin.symbols inserts symbol at wrong position #3217

Closed
powerman opened this issue Jul 23, 2024 · 8 comments · Fixed by #3218 or #3222
Closed

builtin.symbols inserts symbol at wrong position #3217

powerman opened this issue Jul 23, 2024 · 8 comments · Fixed by #3218 or #3222
Labels
bug Something isn't working

Comments

@powerman
Copy link

Description

The symbols picker work in different ways depending on how it was started:

  • If we start builtin picker and then select symbols then everything works correctly (it inserts symbol after a character under cursor).
  • If we start symbols picker then chosen symbol inserted at wrong position (after 2 bytes instead of after 1 character).

Neovim version

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1716656478
Run "nvim -V1 -v" for more info

Operating system and version

Gentoo Linux

Telescope version / branch / rev

master

checkhealth telescope

telescope: health#telescope#check

Checking for required plugins
- OK plenary installed.
- WARNING nvim-treesitter not found. (Required for `:Telescope treesitter`.)

Checking external dependencies
- OK rg: found ripgrep 14.1.0
- OK fd: found fd 9.0.0

===== Installed extensions =====

Steps to reproduce

  1. nvim -u repro.lua
  2. :Telescope symbols then <Enter>
  3. :Telescope symbols then <Enter>

But this one works correctly:

  1. nvim -u repro.lua
  2. :Telescope builtin then symbols<Enter> then <Enter>
  3. :Telescope builtin then symbols<Enter> then <Enter>

Expected behavior

😀😀

Actual behavior

<f0><9f>😀<98><80>

Second emoji was inserted in the middle of the first emoji's bytes.

If try to insert emoji on English text "abc" with cursor at "a" then :Telescope builtinsymbols result in "a😀bc" while :Telescope symbols result in "ab😀c"

Minimal config

--[[ Minimal config to reproduce issues ]]
--
--  Usage: `nvim -u repro.lua`

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify('./.repro', ':p')

-- set stdpaths to use .repro
for _, name in ipairs { 'config', 'data', 'state', 'cache' } do
    vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end

-- bootstrap lazy
local lazypath = root .. '/plugins/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)

-- install plugins
local plugins = {
    'folke/tokyonight.nvim',
    -- add any other plugins here
    {
        'nvim-telescope/telescope.nvim',
        dependencies = 'nvim-lua/plenary.nvim',
        config = true,
    },
    'nvim-telescope/telescope-symbols.nvim',
}
require('lazy').setup(plugins, {
    root = root .. '/plugins',
})

vim.cmd.colorscheme 'tokyonight'
-- add anything else here
@powerman powerman added the bug Something isn't working label Jul 23, 2024
@powerman
Copy link
Author

May be related to #2534

@jamestrew
Copy link
Contributor

Thanks for reporting. Should be fixed now.

@powerman
Copy link
Author

powerman commented Jul 24, 2024

Should be fixed now.

Well, it's almost fixed. Now :Telescope symbols still differ from :Telescope builtinsymbols: first one moves cursor after inserting symbol to one position right while second one does not moves cursor (so it's now on just inserted symbol, which is right behaviour IMO).

@jamestrew
Copy link
Contributor

Are you talking about the position of the cursor and not the location of the symbol placement?
The latter seems fine to me.
https://github.com/user-attachments/assets/eca48ece-a5af-4345-be2b-40ff49351979

The former, I suppose it puts you back in the original buffer in insert mode when doing builtin -> symbols. I think the position is still correct but the mode change could be improved.

@powerman
Copy link
Author

Are you talking about the position of the cursor and not the location of the symbol placement?

Yes.

The latter seems fine to me.

To me too.

The former, I suppose it puts you back in the original buffer in insert mode when doing builtin -> symbols. I think the position is still correct but the mode change could be improved.

I'm not sure. When you press <Esc> just before video ends it became clear: cursor position is on emoji. While in the middle of the video cursor position was on "b" (symbol after emoji). That's the difference I was talking about. INSERT vs NORMAL mode is probably another one difference. Difference in mode may be ok, but difference in cursor position is not ok to me: if you're trying to add 3 emoji in a row you'll get instead a-emoji1-b-emoji2-c-emoji3 which is hardly intuitive and reasonable behaviour.

@jamestrew jamestrew reopened this Jul 25, 2024
@jamestrew
Copy link
Contributor

Ok yeah, that is related to the mode difference since going from insert to normal mode always shifts you one column left.

@jamestrew
Copy link
Contributor

Ok should be all good now. Let me know if there's something else.

@powerman
Copy link
Author

Well, it's a bit non-intuitive because sequental calls of :Telescope symbols inserts emoji not one after another but instead interlacing them with existing symbols in a line… but at least now both ways to call it works the same. Thanks!

BTW, when called using insert-mode keymap it does not have this issue, it inserts emojis in a row, one-by-one. Please don't fix this. 😄

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
2 participants