After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 754949 - Regex match unreliable
Regex match unreliable
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
Depends on:
Blocks: 741728
 
 
Reported: 2015-09-13 10:07 UTC by Egmont Koblinger
Modified: 2015-09-13 13:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix (619 bytes, patch)
2015-09-13 12:16 UTC, Egmont Koblinger
none Details | Review

Description Egmont Koblinger 2015-09-13 10:07:48 UTC
Sometimes vte misses to recognize that the mouse is over a regex (e.g. URL) that should be matched/underlined.

To reproduce:

- Have a text where the matching part is followed by a non-whitespace, e.g. http://example.com/foobar' (the apostrophe is not part of the URL). If you approach the URL from the right within the given row, it won't get underlined, and will not get underlined as long as you move the mouse horizontally within this row (even if you move it out on the left of the URL and re-enter above it from the left). You have to move the mouse vertically to leave this row, and approach the URL from the top, bottom or left to highlight it.

- Have a text where the matching part is preceded by a non-whitespace, e.g. xhttp://example.com/foobar. As you move the mouse from the left to the right, the URL is not yet recognized when the mouse enters 'h', only when it's moved a bit further, over the first 't'.
Comment 1 Egmont Koblinger 2015-09-13 10:30:33 UTC
Re the 2nd case: It doesn't even have to be prefixed by a non-whitespace.
Comment 2 Egmont Koblinger 2015-09-13 11:22:17 UTC
The 2nd is due to a confusion whether match_end.col is inclusive or exclusive. In most of the code it's inclusive, except at the end of vte_terminal_match_check_internal_gregex() which should be "*end = sattr + end_blank - 1;"

<rant>

Die inclusive ends, die die die!

The end pointer should always be exclusive. Or rather, don't think of pointers as pointing to objects. Think about them as pointing between objects, like in python slicing (copying from https://docs.python.org/2/tutorial/introduction.html#strings)

  +---+---+---+---+---+---+
  | P | y | t | h | o | n |
  +---+---+---+---+---+---+
  0   1   2   3   4   5   6
 -6  -5  -4  -3  -2  -1

and you'll never have off-by-one errors any more.

</rant>
Comment 3 Egmont Koblinger 2015-09-13 12:15:37 UTC
Case 1:

Have something like http://example.com/foobar''''

Enter the line vertically over the first apostrophe and move the mouse left -> regex not matched

Enter the line vertically at any other apostrophe then move to the left -> matches

Obviously another off-by-one.
Comment 4 Egmont Koblinger 2015-09-13 12:16:22 UTC
Created attachment 311229 [details] [review]
Fix
Comment 5 Egmont Koblinger 2015-09-13 13:51:39 UTC
Committed, all the way back to 0-36.