[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode a8b7e76e85 171/222: Fix infinite loop in i
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode a8b7e76e85 171/222: Fix infinite loop in indentation. |
Date: |
Sun, 6 Feb 2022 16:59:30 -0500 (EST) |
branch: elpa/typescript-mode
commit a8b7e76e85c1f8b4e353498e3e2d52f1dbcfb6d9
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>
Fix infinite loop in indentation.
This fixes an issue that was introduced in #126
In a case like this:
```
if (...) {
.bleh();
}
```
running indentation on the line with `.bleh()` would (prior to this commit)
result in an infinite loop. The solution is to treat the dot as not being an
expression continuation. It is the start of the expression, not the
continuation
of an expression already started earlier.
---
typescript-mode.el | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/typescript-mode.el b/typescript-mode.el
index 7806053db4..ff2f8674cc 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -2244,19 +2244,31 @@ Searches specifically for any of \"=\", \"}\", and
\"type\"."
"Return non-nil if the current line continues an expression."
(save-excursion
(back-to-indentation)
- (and
- ;; Don't identify the spread syntax or rest operator as a
- ;; "continuation".
- (not (looking-at "\\.\\.\\."))
- (or (typescript--looking-at-operator-p)
- (and (progn
- (typescript--backward-syntactic-ws)
- (or (bobp) (backward-char))
- (and (> (point) (point-min))
- (save-excursion (backward-char) (not (looking-at
"[/*]/")))
- (typescript--looking-at-operator-p)
- (and (progn (backward-char)
- (not (looking-at "++\\|--\\|/[/*]")))))))))))
+ (let ((list-start (nth 1 (syntax-ppss))))
+ (and
+ ;; This not clause is there to eliminate degenerate cases where we have
+ ;; something that looks like a continued expression but we are in fact
at
+ ;; the beginning of the expression. Example: in `if (a) { .q(1)` when
the
+ ;; point is on the dot, the expression that follows looks like a member
+ ;; expression but the object on which it is a member is missing. If we
+ ;; naively treat this as a continued expression, we run into trouble
+ ;; later. (An infinite loop.)
+ (not (and list-start
+ (save-excursion
+ (typescript--backward-syntactic-ws)
+ (backward-char)
+ (eq (point) list-start))))
+ ;; Don't identify the spread syntax or rest operator as a
"continuation".
+ (not (looking-at "\\.\\.\\."))
+ (or (typescript--looking-at-operator-p)
+ (and (progn
+ (typescript--backward-syntactic-ws)
+ (or (bobp) (backward-char))
+ (and (> (point) (point-min))
+ (save-excursion (backward-char) (not (looking-at
"[/*]/")))
+ (typescript--looking-at-operator-p)
+ (and (progn (backward-char)
+ (not (looking-at
"++\\|--\\|/[/*]"))))))))))))
(cl-defun typescript--compute-member-expression-indent ()
"Determine the indent of a member expression.
- [nongnu] elpa/typescript-mode c2d72b7d81 116/222: Fix unwanted indentation after non-keyword "each", (continued)
- [nongnu] elpa/typescript-mode c2d72b7d81 116/222: Fix unwanted indentation after non-keyword "each", ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 0d32c85bfb 110/222: Drop typescript-parent-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5b6d60a2b2 118/222: Fix indentation after keyword-lookalike methods., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 6a6c63ad5e 126/222: Extract test utilities, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 72ec0f93aa 125/222: Merge pull request #90 from jack-williams/add-never, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 69607202bc 139/222: Make GPL license discoverable by Github., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f20103a448 154/222: Add `delete-selection` hints, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode fe63c579b5 158/222: Merge pull request #120 from emacs-typescript/tsx-tests, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode bd15f212a7 165/222: Implement support type-highlighting in some basic declarations, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 444aa36ec2 169/222: Fix the indentation of member expressions and continued expressions., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a8b7e76e85 171/222: Fix infinite loop in indentation.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode 62e0366b46 181/222: Remove debugging code, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a504b6f571 182/222: Merge pull request #1 from jkdufair/jkdufair-remove-debugging-code, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f36fddeb54 186/222: Merge pull request #136 from phst/dup, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 178ceca2d4 188/222: Add option for list items indenting, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2b1f04a166 191/222: Use ‘(should-not …)’ instead of ‘(should (not …))’., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode daded219e6 199/222: Create initial GitHub actions build-definition, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode ab9c2e4fd0 209/222: Merge pull request #153 from emacs-typescript/feature/build-fix, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 67fd5fe4f2 200/222: Delete .travis.yml, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1043025d42 204/222: Merge pull request #143 from jcs-PR/badge, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 3abc9dc6da 006/222: missed table, ELPA Syncer, 2022/02/06