GNU nano - Patches: patch #9801, highlighting empty strings in...
You are not allowed to post comments on this tracker with your current authentication level.
patch #9801: highlighting empty strings in Python
Submitter: | Ryan Westlund <yujiri> | ||
Submitted: | Thu 02 May 2019 04:22:46 PM UTC | ||
Priority: | 3 - Low | Status: | Done |
Privacy: | Public | Assigned to: | bens |
Open/Closed: | Closed | Release: | None |
Jump to the original submission
Sat 11 May 2019 05:12:15 PM UTC, comment #8: |
Benno Schulenberg <bens> |
Sat 11 May 2019 03:49:12 PM UTC, comment #7: I understand now how it works. It is a combination of how regexes work and how nano processes them. A regex matches at the first possible point, and then matches the largest amount of characters possible. So the first part of the changed regex would match an empty string ("") but the second part will match a triple quote ("""), so the latter part is chosen, when possible. And when a regex has matched something, then nano will start a search for a new match after the full length of the last match. This means that matches cannot overlap. And this means that in this case the final quote of a triple can never be the starting quote of a normal mono-quoted string. This is what makes the premature-coloring prevention work. It would not work if the regex were divided over two separate rules like this:
|
Benno Schulenberg <bens> |
Fri 10 May 2019 03:57:21 PM UTC, comment #6: Huh, not sure why it makes a difference to remove the last parts of the first two rules. Regexes will always mystify me.
|
Ryan Westlund <yujiri> |
Mon 06 May 2019 07:27:42 AM UTC, comment #5: I'm thinking of changing the rules for mono-quoted strings to:
|
Benno Schulenberg <bens> |
Sat 04 May 2019 01:39:49 PM UTC, comment #4: Ah, you're right. I was testing in a file with triple double quote docstrings farther down. They behave the same for me (the way single quotes did) in an empty file. (I'm on version 4.2). |
Ryan Westlund <yujiri> |
Fri 03 May 2019 04:06:20 PM UTC, comment #3: I don't see any difference between using triple single quotes (''') and triple double quotes (""") when making docstrings. Maybe your tests gave different results because you have triple single quotes further down in the file but not triple double ones?
|
Benno Schulenberg <bens> |
Fri 03 May 2019 01:10:43 PM UTC, comment #2: Ah, that's something I hadn't noticed before. Apparently it only happens with triple quoted strings using single quotes. Your suggestion seems to fix that issue without causing any additional problems.
|
Ryan Westlund <yujiri> |
Fri 03 May 2019 08:00:57 AM UTC, comment #1: The reason for not highlighting empty strings is that it would make the starting triple quote of a doc string look weird while you are typing the string: the first two quotes would be colored but not the third.
|
Benno Schulenberg <bens> |
Thu 02 May 2019 04:22:46 PM UTC, original submission:
The syntax highlinging module for Python doesn't highlight empty strings. This looks ugly and can get really messed up when you have eg. two empty strings on one line; nano highlights the text between them as green. I found a simple fix. I'll attach the git diff output, since that seems to be how the other patches here are doing it. |
Ryan Westlund <yujiri> |
Depends on the following items: None found
Items that depend on this one: None found
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 7 latest changes.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2019-09-11 | bens | Open/Closed | Open | Closed | |
2019-05-11 | bens | Status | In Progress | Done | |
2019-05-11 | bens | Status | Need Info | In Progress | |
2019-05-03 | bens | Status | None | Need Info | |
Assigned to | None | bens | |||
Summary | Fix syntax highlighting for strings in Python | highlighting empty strings in Python | |||
2019-05-02 | yujiri | Attached File | - | Added diff, #46860 |
Powered by Savane 3.13-d3ae.
Corresponding source code
The change has been pushed to master, commit 8f1cd50f. Thanks for reporting.