bugGNU nano - Bugs: bug #55638, a trailing double-width character...

 
 

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

bug #55638: a trailing double-width character can get mistakenly printed on the next row

Submitter:  Benno Schulenberg <bens>
Submitted:  Mon 04 Feb 2019 08:21:37 AM UTC
   
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  dolorous Open/Closed:  Closed

Jump to the original submission

Fri 08 Mar 2019 07:06:53 PM UTC, comment #12: 

The logic has been amended in master, commit 40a74e46.

Benno Schulenberg <bens>
Group administrator
Tue 05 Mar 2019 10:31:04 PM UTC, comment #11: 

Yes, that seems to work after some quick testing.  I was reluctant to simplify it until I could verify it was working as it was.  Attached new version with that simplified logic.

(file #46438)

David Lawrence Ramsey <dolorous>
Group Member
Tue 05 Mar 2019 07:51:04 PM UTC, comment #10: 

I think the logic can be reduced to:

    if (column > beyond || (*buf != '\0' && (isprompt ||
                                (isdata && !ISSET(SOFTWRAP)))))

Right?

Benno Schulenberg <bens>
Group administrator
Mon 04 Mar 2019 09:54:43 PM UTC, comment #9: 

The logic is now incorrect.  The attached patch against git 37c8232 covers both the case edc0d62 was meant to cover, and all the old cases.

Specifically, it changes the logic back to what it was, and then adds the new case: if we've reached the end of buf, but column has still overshot the screen width, we need to trim it just as we would in the case where we haven't reached the end of buf.

(file #46420)

David Lawrence Ramsey <dolorous>
Group Member
Wed 06 Feb 2019 09:16:10 AM UTC, comment #8: 

Thanks.  Fixed in git, commit edc0d628.

Benno Schulenberg <bens>
Group administrator
Tue 05 Feb 2019 08:56:44 PM UTC, comment #7: 

Attached.

(file #46186)

David Lawrence Ramsey <dolorous>
Group Member
Tue 05 Feb 2019 07:41:58 PM UTC, comment #6: 

Ehm, no, a sign-off is not needed.  I meant a normal commit patch.

Benno Schulenberg <bens>
Group administrator
Tue 05 Feb 2019 07:12:31 PM UTC, comment #5: 

Yeah, after going to bed last night, I realized that the *buf != '\0' part of the check prevented the trimming code from kicking in.  Your change of the logic looks like the right thing.  Please provide a signed-off patch.

Benno Schulenberg <bens>
Group administrator
Tue 05 Feb 2019 07:09:55 AM UTC, comment #4: 

Check that.  I apparently misunderstood this; display_string() is more complex than I thought.

The current logic (in the area of the code changed by git 5283acdc) accounts for the displayed string's being cut off before its end and its trying to display only half of a double-column character.

The problem is caused by a case this logic doesn't handle: the string is not cut off before its end, since it ends with the double-column character; but it does try to display only half of that double-column character due to the spacing's pushing it forward.

The attached experimental patch tweaks the logic to (hopefully) fix this.

(file #46180)

David Lawrence Ramsey <dolorous>
Group Member
Mon 04 Feb 2019 10:20:26 PM UTC, comment #3: 

After looking at the code in detail, I do.  To avoid the problem, index has to be shifted far enough back that the converted is (at least) one column shorter.

The code before commit 5283acdc did this properly, by calculating the position of the character one column before the end.  The code's use of actual_x() meant that almost the entire string would be scanned, but it also guaranteed that index would be one column shorter (or two columns, if one column shorter would be in the middle of a double-width character, since actual_x() won't produce a location in the middle of a character).

Commit 5283acdc broke things by changing the code so that index was shifted one character back, without checking how many columns that character took up.  It broke all cases other than those where the character takes up one column exactly (including zero-width characters).

David Lawrence Ramsey <dolorous>
Group Member
Mon 04 Feb 2019 09:16:48 AM UTC, comment #2: 

The offending commit is 5283acdc, "tweaks: trim a displayable string in a more efficient manner".  But I don't understand why the change is wrong.

Benno Schulenberg <bens>
Group administrator
Mon 04 Feb 2019 08:24:31 AM UTC, comment #1: 

Oops.  Reproduction recipe needs to include --nowrap:

  src/nano --ignore --nowrap +28 NEWS

Benno Schulenberg <bens>
Group administrator
Mon 04 Feb 2019 08:21:37 AM UTC, original submission:  

To reproduce, run 'src/nano --ignore +28 NEWS', then type three periods followed by: M-V 0 0 3 1 1 3 <Home>.  Then press the space bar until the "cactus" reaches the right edge.  Then type one more space.  The cactus is replaced with a $, but... the ㄓ mistakenly appears at the start of the next row.  Press ^L and this spurious ㄓ disappears.

Bug exists since at least version 2.8.1.  Version 2.7.5 and before did not have this "overflow".

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 dolorous (Posted a comment)
  • -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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-25 bens Open/ClosedOpen Closed
    2019-03-05 dolorous Attached File- Added 0001-display-fix-trims-of-double-width-characters-at-the-.patch, #46438
    2019-03-04 dolorous Attached File- Added 0001-display-fix-trims-of-double-width-characters-at-the-.patch, #46420
    2019-02-06 bens StatusIn Progress Fixed
    2019-02-05 dolorous Attached File- Added 0001-display-properly-trim-double-width-characters-at-the.patch, #46186
    2019-02-05 bens StatusNone In Progress
        Assigned toNone dolorous
    2019-02-05 dolorous Attached File- Added double-width-fix.patch, #46180

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code