Optimize editing large files

- Fixed slow editing on large files.
  - Only calculating appearance of lines that are seen.
  - Not resizing all lines when max line length changes.
- Fast changing of syntax highlighting themes.
- Faster startup, since not highlighting all lines.
This commit is contained in:
Andrew Hamilton 2022-03-11 19:20:51 +10:00
parent 938a086188
commit 80048c64f8
3 changed files with 105 additions and 55 deletions

19
tests/diff_editor_test.py Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env python3
import unittest
import diff_edit
class OverlayListTestCase(unittest.TestCase):
def test_overlay_list(self):
self.assertEqual(diff_edit.overlay_list([1, 2, 3, 4], [5, 6], 0), [5, 6, 3, 4])
self.assertEqual(diff_edit.overlay_list([1, 2, 3, 4], [5, 6], 3), [1, 2, 3, 5])
self.assertEqual(diff_edit.overlay_list([1, 2, 3, 4], [5, 6], -1), [6, 2, 3, 4])
self.assertEqual(diff_edit.overlay_list([5, 6], [1, 2, 3, 4], -1), [2, 3])
if __name__ == "__main__":
unittest.main()