bugGNU nano - Bugs: bug #60012, editing a file with a lone triple...

 
 

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

bug #60012: editing a file with a lone triple quote can lead to miscoloring

Submitter:  Benno Schulenberg <bens>
Submitted:  Fri 05 Feb 2021 11:09:55 AM UTC
   
 
Severity:  2 - Minor Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Fri 05 Feb 2021 04:41:59 PM UTC, comment #3: 

Fixed in git, commit 7e04fea9, by setting the multidata of the end match immediately when the match is found.

In theory the multidata for the end match should also get set in the 'seek_an_end' part (there where the data of the current line gets set to WHOLELINE), but I cannot find a situation where this causes miscolorings.

Anyway: even now, with enough jumps and enough edits, things can still get miscolored, but that is something for a later report.

Benno Schulenberg <bens>
Group administrator
Fri 05 Feb 2021 04:21:55 PM UTC, comment #2: 

(Nano gave no warning because the wrong 'syntax=...' gets overridden by the subsequent '-Ypython'.  :|  )

Benno Schulenberg <bens>
Group administrator
Fri 05 Feb 2021 11:31:14 AM UTC, comment #1: 

Ugh.  What I meant, of course, is:

src/nano --rcfile=syntax/python.nanorc -Ypython +444 NEWS

(Why did nano not complain that there is no syntax with the name "syntax/python"?)

Benno Schulenberg <bens>
Group administrator
Fri 05 Feb 2021 11:09:55 AM UTC, original submission:  

To reproduce, run:

src/nano --syntax=syntax/python -Ypython +444 NEWS

Type: ''' ^S ^X
Now open the same file again with the same command.  This will cause the multiline coloring data to be calculated for all lines in the file.

Now type: M-\ '''
See that this colors the whole visible text green, correctly.

Now type: M-/ '''
Oops. The whole visible text gets colored green, wrongly, because the triple quote we just typed is unmatched.

The problem is that when a closing triple quote is offscreen to the bottom, it gets found and correctly interpreted, but its multidata does not get set.  Which means that when later another edit causes backtracking to search for a start match, it will find the unmarked end match and and interpret it as a start match (because start= and end= in the Python syntax can match the same thing).

Now type: M-G 444
See that the text before line 444 is now green, and the text after it not.
Now type: M-/
See that the text is now correctly uncolored.

The jumping to line 444 will correctly set the multidata for that line, marking it as an end match, after which any backtracking from below will honor that marking and will not interpret the line as a start match.

Benno Schulenberg <bens>
Group administrator

 

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

No files currently attached

 

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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-02-25 bens Open/ClosedOpen Closed
    2021-02-05 bens StatusIn Progress Fixed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code