util: Add types & docs for str utils, cleanup old functions#1419
Open
bew wants to merge 8 commits intoL3MON4D3:masterfrom
Open
util: Add types & docs for str utils, cleanup old functions#1419bew wants to merge 8 commits intoL3MON4D3:masterfrom
bew wants to merge 8 commits intoL3MON4D3:masterfrom
Conversation
dff7c22 to
c51c1d8
Compare
bew
commented
Jan 10, 2026
lua/luasnip/util/str.lua
Outdated
| --- Extract a rectangular block of lines in a multiline string area. | ||
| ---@param lines string[] | ||
| ---@param from LuaSnip.Pos00 From this position, MUST be within `lines`. | ||
| ---@param to LuaSnip.Pos00 To this position (excluded), MUST be within `lines` |
Contributor
Author
There was a problem hiding this comment.
should this use LuaSnip.RawPos00 instead ?
Owner
There was a problem hiding this comment.
Sounds reasonable, a buffer is also just a string[], so re-using that indexing scheme is appropriate 👍
bew
commented
Jan 10, 2026
lua/luasnip/util/str.lua
Outdated
| function M.multiline_to_byte_offset(str, pos) | ||
| if pos[1] < 0 or pos[1] + 1 > #str or pos[2] < 0 then | ||
| ---@param lines string[] a multiline string | ||
| ---@param pos LuaSnip.ApiPosition an api-position relative to the start of str. |
Contributor
Author
There was a problem hiding this comment.
This LuaSnip.ApiPosition type is not defined 🤔 What do you want here?
Owner
There was a problem hiding this comment.
Should be RawPos00, I think I'm referring to api-indexing
Contributor
Author
L3MON4D3
reviewed
Jan 18, 2026
L3MON4D3
reviewed
Jan 18, 2026
lua/luasnip/util/str.lua
Outdated
| end | ||
| end | ||
|
|
||
| -- FIXME(@L3MON4D3): not used anywhere? |
Owner
There was a problem hiding this comment.
Oh yeah, leftover from a long time ago (13c5dce 👀)
We no longer use vimscript for registering these file-reload-autocommands, feel free to remove it :)
L3MON4D3
reviewed
Jan 18, 2026
lua/luasnip/util/str.lua
Outdated
| end | ||
|
|
||
| -- modifies strmod | ||
| -- FIXME(@L3MON4D3): not used anywhere? |
Owner
There was a problem hiding this comment.
Yup, left over, get rid of it :D
Owner
|
This is looking really good as well, great work ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from #1396
Depends on #1420