Skip to content

Word sorting creates non-sequential folder numbers when line sorting is enabled and text contains consecutive spaces #12

@scottgeliza

Description

@scottgeliza

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

  1. Enable line and word sorting
  2. Pass text with double spaces: "hi guys"
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions