bugGNU nano - Bugs: bug #57984, justifying can miswrap a paragraph...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #57984: justifying can miswrap a paragraph when the first-line indent differs

Submitter:  Benno Schulenberg <bens>
Submitted:  Wed 11 Mar 2020 12:15:47 PM UTC
   
 
Severity:  2 - Minor Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Thu 12 Mar 2020 11:24:36 AM UTC, comment #2: 

Fixed in git, commit 01477d3b.

(This means that the first word of a paragraph, when it is excessively indented, can be offscreen to the right.  This can't be helped -- nano may not destroy the first-line indentation that the user gave to a paragraph.  If the user does not want such excessive indentation, she shouldn't put it there.)

Benno Schulenberg <bens>
Group administrator
Wed 11 Mar 2020 12:52:56 PM UTC, comment #1: 

Attached patch fixes the problem.

(file #48577)

Benno Schulenberg <bens>
Group administrator
Wed 11 Mar 2020 12:15:47 PM UTC, original submission:  

To reproduce, first creat a testing file:

echo ">>>>   First sentence with five words.  Second sentence"  >quoted
echo ">>>> that continues on second line."  >>quoted


Then run 'src/nano --ignore --fill=12  +2,3 quoted'.
Type: <Shift+Ctrl+Left> twice, so that "Second sentence" and ">>" are selected.  Then type ^J.  Result:


>>>>   First sentence with five words.
>>>>
>>>> Second
>>>> sentence
>>>>   that continues on second line.


This is wrong.  The word "Second" should be on the second line, aligned with "First".

The problem is that rewrap_paragraph() uses just a single lead_len to determine where a break may not be made.  When the paragraph has a first-line indent that is bigger than the later-line indent, then rewrap_paragraph() may mistakenly wrap the first line of the paragraph too early, in the leading indent.

Of course, this is a pathological example: normally one would not choose a wrapping width that is smaller than the length of the word at the start of the paragraph.  So, I'm not sure if I want to try and fix this.

Benno Schulenberg <bens>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-03-25 bens Open/ClosedOpen Closed
    2020-03-12 bens StatusReady For Test Fixed
    2020-03-11 bens Attached File- Added 0001-justify-never-break-a-line-in-leading-whitespace.patch, #48577
        StatusNone Ready For Test
        Assigned toNone bens

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code