GNOME Bugzilla – Bug 754949
Regex match unreliable
Last modified: 2015-09-13 13:51:39 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'.
Re the 2nd case: It doesn't even have to be prefixed by a non-whitespace.
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>
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.
Created attachment 311229 [details] [review] Fix
Committed, all the way back to 0-36.