`LS_SELECT_DEDENT` removes interior whitespace from characterwise selections
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
Read lua/luasnip/util/select.lua around lines 116-130, focusing on the characterwise selection path and its intermediate-line loop. Run the minimal Neovim reproduction and compare visual, linewise, and blockwise selections; done means dedenting removes only applicable leading indentation while preserving interior whitespace such as the gap in "keep gap".
Written by the indexing model from the issue text.
Description
Environment
- LuaSnip:
0abc8f390b278c3b4aabc4c004ac8a088b65cf24(currentmasterwhen checked on 2026-09-16). - Neovim:
0.13.0-dev-1644+gaed60b8a53.
Minimal reproduction
Start Neovim without a user configuration, add a LuaSnip checkout to runtimepath, and configure its built-in selection mapping:
vim.opt.runtimepath:prepend("/path/to/LuaSnip")
vim.keymap.set("x", "<F5>", require("luasnip").cut_keys)
And the file content:
first
keep gap
last
From Normal mode, type gg^vjj$ (^v is not Ctrl + V), then press <F5>. Leave Insert mode and inspect:
:lua print(vim.inspect(vim.fn.visualmode()))
:lua print(vim.inspect(vim.b.LUASNIP_SELECT_DEDENT))
Expected:
{ "first", " keep gap", "last" }
Actual:
{ "first", " keepgap", "last" }
The four spaces inside keep gap are deleted even though they are part of the selected content, not indentation. LUASNIP_SELECT_RAW still contains them.
Starting again from the original text, the three selection modes give this comparison:
Selection keys before <F5> |
visualmode() |
Middle line after dedenting |
|---|---|---|
gg^vjj$ |
"v" |
" keepgap" (the bug) |
ggVjj |
"V" |
" keep gap" |
gg<C-v>jj$ |
"\22" |
" keep gap" |
Relevant implementation
The characterwise path uses unanchored gsub(min_indent, "") calls in select.lua. In particular, the loop over intermediate lines removes every matching run, including whitespace inside the line body. The linewise path anchors its removal at the beginning of each line.
The expected behavior is to remove only the applicable leading indentation and preserve the rest of the selected content.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 269
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from L3MON4D3/LuaSnip
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
All issues in L3MON4D3/LuaSnip
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
api7/lua-resty-saml#62 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
nvim-tree/nvim-tree.lua#3357 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
codymikol/multiverse.nvim#320 ·
-
Data Correction tbc
Difficulty 2/5 1-3 hours Newbie friendliness 68/100