Expected Behavior
When line and word sorting are enabled and text contains consecutive spaces (e.g., "hi guys"), only non-empty words should get folders, numbered sequentially: 1, 2
Actual Behavior
Empty words caused by consecutive spaces are represented as false in the words table. When iterating with for wordIndex, word in words do, the wordIndex includes positions of empty words, causing gaps in folder numbering.
Result: Folders are numbered 1, 3 instead of 1, 2
Steps to Reproduce
- Enable line and word sorting
- Pass text with double spaces:
"hi guys"
- Observe created folders are numbered: 1, 3 (missing 2)
Root Cause
The words table structure includes false entries for empty words:
[1] = { {["h"], 17.4}, {["i"], 7.8} }, -- word 1
[2] = false, -- empty word (skipped)
[3] = { {["g"], 16.2}, ... } -- word 3
The code uses wordIndex from the iterator for naming, which reflects the table position (including false entries) rather than counting only created folders.
Expected Behavior
When line and word sorting are enabled and text contains consecutive spaces (e.g.,
"hi guys"), only non-empty words should get folders, numbered sequentially: 1, 2Actual Behavior
Empty words caused by consecutive spaces are represented as
falsein thewordstable. When iterating withfor wordIndex, word in words do, thewordIndexincludes positions of empty words, causing gaps in folder numbering.Result: Folders are numbered 1, 3 instead of 1, 2
Steps to Reproduce
"hi guys"Root Cause
The
wordstable structure includesfalseentries for empty words:The code uses
wordIndexfrom the iterator for naming, which reflects the table position (includingfalseentries) rather than counting only created folders.