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

Custom surround <M-]> doesn't work since v2.1.3 #325

Closed
3 tasks done
bew opened this issue May 27, 2024 · 1 comment · Fixed by #326
Closed
3 tasks done

Custom surround <M-]> doesn't work since v2.1.3 #325

bew opened this issue May 27, 2024 · 1 comment · Fixed by #326
Labels
bug Something isn't working

Comments

@bew
Copy link
Contributor

bew commented May 27, 2024

Checklist

  • Have you tried updating the plugin to the latest version?
  • Have you checked the Breaking Changes issue?
  • Have you read through :h nvim-surround to see if there might be any relevant information there?

Neovim Version

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1693350652

Plugin Version

Tagged (Stable)

Minimal Configuration

(note I use these in Lua files, to ease changing [[ ... ]]-based strings)

require('nvim-surround').setup {
  surrounds = {
    ["<M-[>"] = {
      add = { "[[ ", " ]]" },
      find = vim.pesc"[[" .. ".-" .. vim.pesc"]]",
      delete = (
        "^" ..
        "(" .. vim.pesc"[[" .. "%s*)()" .. -- removes any number of spaces
        ".-" ..
        "(%s*" .. vim.pesc"]]" .. ")()" .. -- removes any number of spaces
        "$"
      )
    },
    ["<M-]>"] = {
      add = { "[[", "]]" },
      find = vim.pesc"[[" .. ".-" .. vim.pesc"]]",
      delete = (
        "^" ..
        "(" .. vim.pesc"[[" .. ")()" ..
        ".-" ..
        "(" .. vim.pesc"]]" .. ")()" ..
        "$"
      )
    }
  }
}

Sample Buffer

[[  foobar  ]]

Keystroke Sequence

  1. fb
  2. cs <M-[> <M-]>
  3. ds <M-]>

Expected behavior

  • After 1., buffer should be [[foobar]]
  • After 2., buffer should be foobar

Actual behavior

Nothing happens

Additional context

I bisected the issue to cfa2da7

And neovim devs mentioned to me that calling nvim_replace_termcodes on the result of getcharstr is wrong, the output of getcharstr is already the raw chars!
See neovim/neovim#29034

@bew bew added the bug Something isn't working label May 27, 2024
bew added a commit to bew/nvim-surround that referenced this issue May 27, 2024
`getcharstr()` already returns raw internal termcodes, it is wrong to
call nvim_replace_termcodes on its result.

This effectively reverts PR kylechui#273

refs: neovim/neovim#29034
fixes: kylechui#325
bew added a commit to bew/nvim-surround that referenced this issue May 27, 2024
`getcharstr()` already returns raw internal termcodes, it is wrong to
call nvim_replace_termcodes on its result.

This effectively reverts PR kylechui#273

refs: neovim/neovim#29034
fixes: kylechui#325
kylechui pushed a commit to bew/nvim-surround that referenced this issue May 29, 2024
`getcharstr()` already returns raw internal termcodes, it is wrong to
call nvim_replace_termcodes on its result.

This effectively reverts PR kylechui#273

refs: neovim/neovim#29034
fixes: kylechui#325
kylechui pushed a commit to bew/nvim-surround that referenced this issue May 30, 2024
`getcharstr()` already returns raw internal termcodes, it is wrong to
call nvim_replace_termcodes on its result.

This effectively reverts PR kylechui#273

refs: neovim/neovim#29034
fixes: kylechui#325
bew added a commit to bew/nvim-surround that referenced this issue May 30, 2024
`getcharstr()` already returns raw internal termcodes, it is wrong to
call nvim_replace_termcodes on its result.

This effectively reverts PR kylechui#273

refs: neovim/neovim#29034
fixes: kylechui#325
kylechui pushed a commit that referenced this issue May 30, 2024
* Don't translate termcodes twice on input

`getcharstr()` already returns raw internal termcodes, it is wrong to
call nvim_replace_termcodes on its result.

This effectively reverts PR #273

refs: neovim/neovim#29034
fixes: #325

* Add tests for multi-byte mappings
@kylechui
Copy link
Owner

kylechui commented May 30, 2024

Oh yeah I just tagged this change under 2.1.10, so you can update to that instead of tracking HEAD.

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.

2 participants