diff options
| author | kobarity | 2023-06-02 22:52:57 +0900 |
|---|---|---|
| committer | Eli Zaretskii | 2023-06-03 10:09:33 +0300 |
| commit | 6b2c8dc9050c5c0514fa404733ce1d4a37d00e39 (patch) | |
| tree | fe44b5ae27d89cccbcad97efda16fa063ac5fe1c /test/lisp/progmodes/python-tests.el | |
| parent | 348e4504c6d5588443809ec28da3c3c693368e16 (diff) | |
| download | emacs-6b2c8dc9050c5c0514fa404733ce1d4a37d00e39.tar.gz emacs-6b2c8dc9050c5c0514fa404733ce1d4a37d00e39.zip | |
Revert "Enhance Python font-lock to support multilines"
This reverts commit 4915ca5dd4245a909c046e6691e8d4a1919890c8.
We have found that there are performance issues when editing a large
file. The issue can be reproduced as follows:
1. emacs -Q
2. Open large Python file (e.g. turtle.py in Python)
3. Near the top of the buffer, enter open paren and some characters.
The above commit extends the region to be font-locked using
`python-nav-end-of-statement'. However, if there are unbalanced
parens, it may move point to the end of the buffer. This causes
almost the entire buffer to be font-locked, which is not acceptable
for large files.
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
| -rw-r--r-- | test/lisp/progmodes/python-tests.el | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index cbaf5b698bd..e1b4c0a74c0 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el | |||
| @@ -136,20 +136,6 @@ STRING, it is skipped so the next STRING occurrence is selected." | |||
| 136 | while pos | 136 | while pos |
| 137 | collect (cons pos (get-text-property pos 'face)))) | 137 | collect (cons pos (get-text-property pos 'face)))) |
| 138 | 138 | ||
| 139 | (defun python-tests-assert-faces-after-change (content faces search replace) | ||
| 140 | "Assert that font faces for CONTENT are equal to FACES after change. | ||
| 141 | All occurrences of SEARCH are changed to REPLACE." | ||
| 142 | (python-tests-with-temp-buffer | ||
| 143 | content | ||
| 144 | ;; Force enable font-lock mode without jit-lock. | ||
| 145 | (rename-buffer "*python-font-lock-test*" t) | ||
| 146 | (let (noninteractive font-lock-support-mode) | ||
| 147 | (font-lock-mode)) | ||
| 148 | (while | ||
| 149 | (re-search-forward search nil t) | ||
| 150 | (replace-match replace)) | ||
| 151 | (should (equal faces (python-tests-get-buffer-faces))))) | ||
| 152 | |||
| 153 | (defun python-tests-self-insert (char-or-str) | 139 | (defun python-tests-self-insert (char-or-str) |
| 154 | "Call `self-insert-command' for chars in CHAR-OR-STR." | 140 | "Call `self-insert-command' for chars in CHAR-OR-STR." |
| 155 | (let ((chars | 141 | (let ((chars |
| @@ -297,13 +283,6 @@ p = (1 + 2) | |||
| 297 | "def 1func():" | 283 | "def 1func():" |
| 298 | '((1 . font-lock-keyword-face) (4)))) | 284 | '((1 . font-lock-keyword-face) (4)))) |
| 299 | 285 | ||
| 300 | (ert-deftest python-font-lock-keywords-level-1-3 () | ||
| 301 | (python-tests-assert-faces | ||
| 302 | "def \\ | ||
| 303 | func():" | ||
| 304 | '((1 . font-lock-keyword-face) (4) | ||
| 305 | (15 . font-lock-function-name-face) (19)))) | ||
| 306 | |||
| 307 | (ert-deftest python-font-lock-assignment-statement-1 () | 286 | (ert-deftest python-font-lock-assignment-statement-1 () |
| 308 | (python-tests-assert-faces | 287 | (python-tests-assert-faces |
| 309 | "a, b, c = 1, 2, 3" | 288 | "a, b, c = 1, 2, 3" |
| @@ -495,129 +474,6 @@ def f(x: CustomInt) -> CustomInt: | |||
| 495 | (136 . font-lock-operator-face) (137) | 474 | (136 . font-lock-operator-face) (137) |
| 496 | (144 . font-lock-keyword-face) (150)))) | 475 | (144 . font-lock-keyword-face) (150)))) |
| 497 | 476 | ||
| 498 | (ert-deftest python-font-lock-assignment-statement-multiline-1 () | ||
| 499 | (python-tests-assert-faces-after-change | ||
| 500 | " | ||
| 501 | [ | ||
| 502 | a, | ||
| 503 | b | ||
| 504 | ] # ( | ||
| 505 | 1, | ||
| 506 | 2 | ||
| 507 | ) | ||
| 508 | " | ||
| 509 | '((1) | ||
| 510 | (8 . font-lock-variable-name-face) (9) | ||
| 511 | (15 . font-lock-variable-name-face) (16) | ||
| 512 | (19 . font-lock-operator-face) (20)) | ||
| 513 | "#" "=")) | ||
| 514 | |||
| 515 | (ert-deftest python-font-lock-assignment-statement-multiline-2 () | ||
| 516 | (python-tests-assert-faces-after-change | ||
| 517 | " | ||
| 518 | [ | ||
| 519 | *a | ||
| 520 | ] # 5, 6 | ||
| 521 | " | ||
| 522 | '((1) | ||
| 523 | (8 . font-lock-operator-face) | ||
| 524 | (9 . font-lock-variable-name-face) (10) | ||
| 525 | (13 . font-lock-operator-face) (14)) | ||
| 526 | "#" "=")) | ||
| 527 | |||
| 528 | (ert-deftest python-font-lock-assignment-statement-multiline-3 () | ||
| 529 | (python-tests-assert-faces-after-change | ||
| 530 | "a\\ | ||
| 531 | ,\\ | ||
| 532 | b\\ | ||
| 533 | ,\\ | ||
| 534 | c\\ | ||
| 535 | #\\ | ||
| 536 | 1\\ | ||
| 537 | ,\\ | ||
| 538 | 2\\ | ||
| 539 | ,\\ | ||
| 540 | 3" | ||
| 541 | '((1 . font-lock-variable-name-face) (2) | ||
| 542 | (15 . font-lock-variable-name-face) (16) | ||
| 543 | (29 . font-lock-variable-name-face) (30) | ||
| 544 | (36 . font-lock-operator-face) (37)) | ||
| 545 | "#" "=")) | ||
| 546 | |||
| 547 | (ert-deftest python-font-lock-assignment-statement-multiline-4 () | ||
| 548 | (python-tests-assert-faces-after-change | ||
| 549 | "a\\ | ||
| 550 | :\\ | ||
| 551 | int\\ | ||
| 552 | #\\ | ||
| 553 | 5" | ||
| 554 | '((1 . font-lock-variable-name-face) (2) | ||
| 555 | (15 . font-lock-builtin-face) (18) | ||
| 556 | (24 . font-lock-operator-face) (25)) | ||
| 557 | "#" "=")) | ||
| 558 | |||
| 559 | (ert-deftest python-font-lock-assignment-statement-multiline-5 () | ||
| 560 | (python-tests-assert-faces-after-change | ||
| 561 | "(\\ | ||
| 562 | a\\ | ||
| 563 | )\\ | ||
| 564 | #\\ | ||
| 565 | 5\\ | ||
| 566 | ;\\ | ||
| 567 | (\\ | ||
| 568 | b\\ | ||
| 569 | )\\ | ||
| 570 | #\\ | ||
| 571 | 6" | ||
| 572 | '((1) | ||
| 573 | (8 . font-lock-variable-name-face) (9) | ||
| 574 | (18 . font-lock-operator-face) (19) | ||
| 575 | (46 . font-lock-variable-name-face) (47) | ||
| 576 | (60 . font-lock-operator-face) (61)) | ||
| 577 | "#" "=")) | ||
| 578 | |||
| 579 | (ert-deftest python-font-lock-assignment-statement-multiline-6 () | ||
| 580 | (python-tests-assert-faces-after-change | ||
| 581 | "( | ||
| 582 | a | ||
| 583 | )\\ | ||
| 584 | #\\ | ||
| 585 | 5\\ | ||
| 586 | ;\\ | ||
| 587 | ( | ||
| 588 | b | ||
| 589 | )\\ | ||
| 590 | #\\ | ||
| 591 | 6" | ||
| 592 | '((1) | ||
| 593 | (7 . font-lock-variable-name-face) (8) | ||
| 594 | (16 . font-lock-operator-face) (17) | ||
| 595 | (43 . font-lock-variable-name-face) (44) | ||
| 596 | (56 . font-lock-operator-face) (57)) | ||
| 597 | "#" "=")) | ||
| 598 | |||
| 599 | (ert-deftest python-font-lock-operator-1 () | ||
| 600 | (python-tests-assert-faces | ||
| 601 | "1 << 2 ** 3 == +4%-5|~6&7^8%9" | ||
| 602 | '((1) | ||
| 603 | (3 . font-lock-operator-face) (5) | ||
| 604 | (8 . font-lock-operator-face) (10) | ||
| 605 | (13 . font-lock-operator-face) (15) | ||
| 606 | (16 . font-lock-operator-face) (17) | ||
| 607 | (18 . font-lock-operator-face) (20) | ||
| 608 | (21 . font-lock-operator-face) (23) | ||
| 609 | (24 . font-lock-operator-face) (25) | ||
| 610 | (26 . font-lock-operator-face) (27) | ||
| 611 | (28 . font-lock-operator-face) (29)))) | ||
| 612 | |||
| 613 | (ert-deftest python-font-lock-operator-2 () | ||
| 614 | "Keyword operators are font-locked as keywords." | ||
| 615 | (python-tests-assert-faces | ||
| 616 | "is_ is None" | ||
| 617 | '((1) | ||
| 618 | (5 . font-lock-keyword-face) (7) | ||
| 619 | (8 . font-lock-constant-face)))) | ||
| 620 | |||
| 621 | (ert-deftest python-font-lock-escape-sequence-string-newline () | 477 | (ert-deftest python-font-lock-escape-sequence-string-newline () |
| 622 | (python-tests-assert-faces | 478 | (python-tests-assert-faces |
| 623 | "'\\n' | 479 | "'\\n' |