Skip to content

Comments

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

Open
miyake13000 wants to merge 1 commit intonomlab:masterfrom
miyake13000:master
Open

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

Conversation

@miyake13000
Copy link

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

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