diff options
author | Avinash Thakur <19588421+80avin@users.noreply.github.com> | 2025-03-19 20:17:59 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-19 14:47:59 +0000 |
commit | 424f4cc0389ed883f220bd5cbab9c07b4955acde (patch) | |
tree | 10ed59629f0cfc533fc18e7f16cb5d49be6f6296 /runtime/lua/vim/lsp/util.lua | |
parent | 42db8b17594e2a911396e8f8eea8cbfa8ddf0de2 (diff) | |
download | rneovim-424f4cc0389ed883f220bd5cbab9c07b4955acde.tar.gz rneovim-424f4cc0389ed883f220bd5cbab9c07b4955acde.tar.bz2 rneovim-424f4cc0389ed883f220bd5cbab9c07b4955acde.zip |
fix(snippet): wrong indentation when snippet contains "^" #32970
## Problem
The pattern used to match indentation is wrong as can be seen in
```lua
-- current pattern doesn't match starting space
print(vim.inspect((" xyz"):match("(^%s+)%S")))
-- nil
-- instead, it matches characters `^ ` in text
print(vim.inspect(("x^ yz"):match("(^%s+)%S")))
-- "^ "
-- indentation could've been matched by, however not required
print(vim.inspect((" xyz"):match("^(%s+)%S")))
-- " "
```
## Solution
We don't even need to modify `base_indent` at every line. If every line's indentation is calculated by the previous line's indentation (which already has starting indentation) added to the starting indentation, we see that indentation is multiplied on every line.
Hence, we only add the starting line indentation to every line.
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
0 files changed, 0 insertions, 0 deletions