For all languages, this change allows comments at the end of the
checked line, e.g.:
if 42: # magic number
print("I'm indented!")
For languages with braces, it also properly indent if there is code
on the same line as the opening brace, e.g.:
if (42) { printf("some code here...");
printf("...but I'm properly indented");
} else { /* comment! */
printf("normal block is fine too, of course");
}
Although this is uncommon (and quite ugly) it's valid and should be
handled properly.
f4eb89cd7d79738a9c6c45e29abdd9d15d22e4fd was partially wrong and
removed legitimate re-matches when two different matches ends at the
same position. Particularly, the replacement changes are reverted.
Interestingly, Perl and Python does not agree on how to do such
replacements. Python does what I did in the above-cited commit, e.g.
doesn't replace twice if the match end overlaps, but Perl does.
Perl looks more legitimate here since both Python and Perl does find
the overlapping matches when performing a search, so Python is the odd
guy here doing it differently on replace than it does upon search.
For example, replacing using the pattern "a?(?=b)" and the replacement
string "_":
Python: ababcdb -> _b_bcd_b
Perl: ababcdb -> __b__bcd_b
But finding using the same pattern on the same input gives the same
results on both:
Python: ababcdb -> ['a', '', 'a', '', '']
Perl: ababcdb -> ['a', '', 'a', '', '']
Anyway, GLib and us claim to support "Perl-compatible regular
expressions", so we gotta follow Perl, especially in such doubtful
situations.
Regular expressions might match empty ranges, which weren't handled
properly, but generally simply omitted.
For example, the regular expression "^$" (empty line) never matched
because we assumed empty results were not interesting, and actually
needed more care in the code. Alike, an expression matching only on
its lookahead part, like "a?(?=b)" against "b", would stop further
search, although it could even match a non-empty range if "ab" is
present later in the input. This last kind of expressions also lead
to double-replacement because they first matched "ab" and then "b"
alone when re-matching after the "a" replacement.
This commit fixes:
* searching when the matched range is empty;
* step-by-step search when matching an empty range;
* double replacement when the pattern re-matches an empty range
straight after a replacement;
* replacement to and empty string when the matching an empty range.
A know issue though is the step-by-step replacement that won't replace
an empty match but rather find the next match.
If a search matched the very last character of the document, next
search attempt started out of the document bounds. This even lead
to an infinite loop due to an improper sanity check.
By the way, this fixes matching of contiguous results, as the next
search used to improperly skip one character after the result.
Although this looks like a huge issue, it was actually visible almost
only on the match count since the whole matching line was printed.
Use the current document's directory unless the directory field has
already been edited and the current document has not changed.
Otherwise, prepend the current document's directory to the drop-down
history in case it is wanted.
This is useful to avoid losing the edited directory when it is less
likely the user wants to use the current document's directory.
Previously it was using a GLIB assertion which shouldn't be used
to detect a normal condition and so it caused a warning on the
console output when clicking "Reload" with an "untitled" document.
We explicitly use GModule's .pc since 7b2f0fe, and it provides the
appropriate flag: we don't need to add it ourselves anymore. Moreover,
since this flag is not needed (nor available) on all platforms (e.g.
Windows or MacOS X), it is safer to let GModule deal with adding it
anyway.
Scintilla deprecated SCI_GETUSEPALETTE and SCI_SETUSEPALETTE messages,
and since we don't build with deprecated API support they aren't
available anymore.
This moves CTags files into their own subdirectory and moves the
tagmanager source and header files into their own subdirectory.
The bulk of the work was done by Colomban.