strings.truncate can freeze when in a fast event/strings.strcharpart's fallback is used
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 88/100
Research direction
Open lua/plenary/strings.lua and inspect the strings.strcharpart fallback around the referenced lines, then trace how truncate calls it for positive direction. Verify that the fallback’s substring behavior matches the stated start-and-length expectation and that truncate("test string", 5, "...", 1) completes instead of freezing.
Written by the indexing model from the issue text.
Description
(I saw the no longer maintained sign, consider this for documentation purposes or something)
there's an oopsie in strings.strcharpart's fallback function. sub takes start and end positions, and not start and length like vim's strcharpart:
https://github.com/nvim-lua/plenary.nvim/blob/74b06c6c75e4eeb3108ec01852001636d85a932b/lua/plenary/strings.lua#L42-L45
when this fallback function is used, the truncate function can get stuck in an infinite loop whenever the direction is positive and the string is long enough to be truncated. for example, this freezes in a fast state:
truncate("test string", 5, "...", 1)
to fix this, I think the fallback just needs to be: return str:sub(nchar + 1, nchar + charlen)
- Dominant language
- Lua
- Stars
- 3.5k
- Forks
- 340
- 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 nvim-lua/plenary.nvim
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
nvim-lua/plenary.nvim#680 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
nvim-lua/plenary.nvim#675 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
nvim-lua/plenary.nvim#672 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
nvim-lua/plenary.nvim#671 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
nvim-lua/plenary.nvim#670 ·
All issues in nvim-lua/plenary.nvim
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