Only apply highlights to visible portion of buffer#5434
Only apply highlights to visible portion of buffer#5434bscuron wants to merge 1 commit intomawww:masterfrom
Conversation
|
Is there a correctness issue where jumping into the middle of a region causes it to be highlighted incorrectly? For example, if a file has a |
Ah it does not correctly apply a highlight in this case. It looks like vim handles this in a few different ways: syntax synchronizing. Of those ways, this simplest would be to scan the previous n lines when applying highlights. |
|
Regions are by design applied to the whole buffer, in order to be fully correct. We do a few compromises in order to make them fast, most notably not allowing region start/end to span multiple lines. What you measure here is the initial work that needs to be done to get all matches, but after that regions are updated incrementally based off changes made to the buffer and should be fast enough. Have you noticed performance issue past the first display of the large buffer ? Or only on load time ? |
There seems to be some sort of performance impact even past initial load. For example, when opening a large file, creating a selection for each character 'e' and typing some text. Currently, each selection enters
The output txt file for the master branch contains all selection ranges. The output txt file for this branch contains only the visible ranges. Another note: after running the test on the master branch, delete the txt file without closing kak. Create many selections again and make an edit. The selection ranges are there again. It looks like each selection range would be reevaluated on each keystroke across the whole buffer. |
|
yes, whenever a line is changed, any cached highlighting is invalidated. |
cat src/*.cc src/*.hh > test.ccperf record ./src/kak test.ccBefore:
81.36% Kakoune::RegionsHighlighter::MatchAdder::add(Kakoune::Range<Kakoune::LineCount>)After:
0.36% Kakoune::RegionsHighlighter::MatchAdder::add(Kakoune::Range<Kakoune::LineCount>)This noticeably improves performance in larger files.
All tests still pass.