Skip to content

Fix a bug for using greedy match to get indent width#12

Merged
miyake13000 merged 1 commit intonomlab:masterfrom
miyake13000:master
Feb 26, 2026
Merged

Fix a bug for using greedy match to get indent width#12
miyake13000 merged 1 commit intonomlab:masterfrom
miyake13000:master

Conversation

@miyake13000
Copy link
Copy Markdown

Overview

Before:

  • Using greedy match to get indent width when wrapping line

  • Example:

    + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
    • This is converted to:
    (A) xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        xxxxxxxxxxxx
    
    • However, in below case...
    + xxxxxxxxxxxxxxxxxxxx (foo) xxxxxxxxxxxxxx
    
    • Internaly, this is converted to
    (A) xxxxxxxxxxxxxxxxxxxx (foo) xxxxxxxxxxxxxx
    ↑    greedy  match result    ↑
    
    • So, this becomes
    (A) xxxxxxxxxxxxxxxxxxxx (foo) xxxxxxx
                                   xxxxxxx
    
  • And, this indent mistake cause a bug because

    • If paragraph_position (L. 828) sets position to exceed max_width, infinity recursive calls occurs in fill_column (L. 856)

After:

  • Fix regex to use lazy match (.+ -> .*?)

  • Example:

    (A) xxxxxxxxxxxxxxxxxxxx (foo) xxxxxxxxxxxxxx
    ↑ ↑ match
    
    • This is converted to
    (A) xxxxxxxxxxxxxxxxxxxx (foo) xxxxxxx
        xxxxxxx
    
  • And, fix rege from .+ -> .* so that regex matches even when the parentheses are empty

@miyake13000 miyake13000 merged commit c839a30 into nomlab:master Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant