BUGFIX (definitive) for regex search matching deleted text #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reverts the bug-fixing workaround introduced as part of commit f751537 that required to modify Scintilla's own code base by adding new members to the
Scintilla::Document()
,Scintilla::CellBuffer()
&Scintilla::SplitVector()
class.Quick recap on the bug
The bug arose from the need to plug the new regular expression engine, Onigmo, into Scintilla's built-in RegexSearchBase interface for its use as a custom regex engine. While the Onimo engine expects to have direct access to a text buffer to search from, Scintilla can provide such access but care must be taken as Scintilla, internally, uses a gap buffer and its location must be considered when reading characters from it, as it can lead to false positives when searching for regex matches, although in very specific, edge cases.
For example, if characters were to be suppressed from the end of an existing using the
<Backspace>
key, then searching with regex pattern that would otherwise have captured both those suppressed characters—but not, incidentally and in such very specific cases, that same end of line without those now-suppressed chars—would effectively find a match for that end of line, erroneously, simply because those suppressed chars remain in Scintilla's gap buffer until their effective removal is triggered by moving the insertion cursor elsewhere of until the text is changed elsewhere in the open document.The original solution was to patch Scintilla's own code directly by cloning the existing
CellBuffer::RangePointer()
into a new method,CellBuffer::DataPointer()
(as well as for its analog on the Document interface) , with the difference that that new method would actively move the buffer gap out of the way / at the end of the range specified in the method call, such that the pointer returned would always be for a contiguous block of text.Although negating the performance benefit of having a buffer gap (but with the penalty only occurring when initiating a search), the real problem with the original fix is that it changed directly Scintilla's code, and as such any in-place upgrade of Scintilla is « impossible » (i.e. causes a regression of the bug) unless the fix is replicated on Scintilla's updated codebase, if it can be at all.
The definitive fix of the bug
The need for updating Scintilla's code is pretty much a given, for the simple reason that doing so fixes many other bugs but also patches known security vulnerabilities. While contemplating such update, finding a more permanent fix (or workaround) for the bug became a priority.