[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 4235b47a38 060/222: Fix indent for lines w
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 4235b47a38 060/222: Fix indent for lines which starts with tabs. |
Date: |
Sun, 6 Feb 2022 16:59:16 -0500 (EST) |
branch: elpa/typescript-mode
commit 4235b47a389bf04a95fa54e59695f60599dc918b
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>
Fix indent for lines which starts with tabs.
This closes https://github.com/ananthakumaran/typescript.el/issues/37
---
typescript-mode-tests.el | 37 ++++++++++++++++++++++++++-----------
typescript-mode.el | 12 ++----------
2 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/typescript-mode-tests.el b/typescript-mode-tests.el
index f1bd21be2a..000e9b3484 100644
--- a/typescript-mode-tests.el
+++ b/typescript-mode-tests.el
@@ -99,21 +99,36 @@ a severity set to WARNING, no rule name."
(should (string-equal (nth 4 matches) "1"))
(should (string-equal (nth 5 matches) "83"))))
-(ert-deftest correctly-accounts-wide-chars-as-1-char ()
+(ert-deftest correctly-indents-lines-with-wide-chars ()
"Otsuka Ai and other multi-char users should be a happy to write typescript."
(with-temp-buffer
- (insert "大塚愛")
- (should (equal 3 (typescript--current-column)))))
-
-(ert-deftest correctly-accounts-wide-chars-as-1-char-without-sideeffects ()
- "Otsuka Ai and other multi-char users should be a happy to write typescript."
-
+ (ignore-errors (typescript-mode))
+ (insert "let x = '大塚愛'")
+ (let ((pos1 (current-column)))
+ (typescript-indent-line)
+ (let ((pos2 (current-column)))
+ (should (= pos1 pos2))))))
+
+(ert-deftest correctly-indents-lines-with-tabs ()
(with-temp-buffer
- (insert "大塚愛")
- (let ((pos1 (typescript--current-column))
- (pos2 (typescript--current-column)))
- (should (equal pos1 pos2)))))
+ (ignore-errors (typescript-mode))
+
+ (insert "class Example {")
+ (newline-and-indent)
+ (insert "constructor() {")
+ (newline-and-indent)
+ (insert "const a = new Promise")
+
+ (should (= 29 (current-column)))
+ (typescript-indent-line)
+ (should (= 29 (current-column)))
+
+ ;; verify tab was used
+ (move-beginning-of-line nil)
+ (should (= 0 (current-column)))
+ (forward-char 1)
+ (should (= 8 (current-column)))))
(provide 'typescript-mode-tests)
diff --git a/typescript-mode.el b/typescript-mode.el
index 12840a00f1..c8866839e5 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1795,14 +1795,6 @@ nil."
(+ typescript-indent-level typescript-expr-indent-offset))
(t 0))))
-(defun typescript--current-column ()
- "Unicode aware version of `CURRENT-COLUMN' which correctly accounts for wide
characters."
-
- (save-excursion
- (let ((end (point)))
- (move-beginning-of-line nil)
- (- end (point)))))
-
(defun typescript-indent-line ()
"Indent the current line as typescript."
(interactive)
@@ -1810,9 +1802,9 @@ nil."
(widen)
(let* ((parse-status
(save-excursion (syntax-ppss (point-at-bol))))
- (offset (- (typescript--current-column) (current-indentation))))
+ (offset (- (current-column) (current-indentation))))
(indent-line-to (typescript--proper-indentation parse-status))
- (when (> offset 0) (forward-char offset)))))
+ (when (> offset 0) (move-to-column (+ offset (current-indentation)))))))
;;; Filling
- [nongnu] elpa/typescript-mode d27114244a 014/222: added "abstract" keyword, (continued)
- [nongnu] elpa/typescript-mode d27114244a 014/222: added "abstract" keyword, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 54e0c562d4 020/222: removed keyword "bool" which is deprecated since TypeScript 0.9, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d81cc72782 013/222: Merge pull request #7 from paulkoerbitz/patch-1, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a532ef57cf 046/222: Merge pull request #29 from lddubeau/fix/method-generator, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode c1a7d40dd8 005/222: highlight template string, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 8fe879a96d 028/222: Support 'of' keyword., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode ca510ab853 048/222: Merge pull request #30 from lddubeau/fix/keyword-members, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a2c2ff03e7 024/222: Add support for compilation-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7526f138a0 032/222: Avoid capturing things we dont need for compilation-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 666052f09f 033/222: Update readme., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4235b47a38 060/222: Fix indent for lines which starts with tabs.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode 52c08d0628 091/222: Add more fontification tests for regular expressions., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e25c7ddb8a 062/222: Fix indentation of funcs with return annotations., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 536e4da380 087/222: Fix bug with hanling array shorthand in return value types., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 70acbf9c3d 078/222: Change font-lock-test to also accept a list of locations, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a2167a133d 056/222: Fix errors with indentation when line has wide unicode chars., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 09bdb97c32 065/222: Fix an indentation bug., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 8b2815514d 088/222: Simplify typescript--backward-to-parameter-list, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f9cd0dd539 112/222: Try parse new error-format introduced in tsc 2.7+, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a1cdb7a1ec 121/222: Remove redundant regexp groups for jsdoc tags, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode fd1c9daa4d 094/222: Add failing cases., ELPA Syncer, 2022/02/06