[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode a2167a133d 056/222: Fix errors with indent
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode a2167a133d 056/222: Fix errors with indentation when line has wide unicode chars. |
Date: |
Sun, 6 Feb 2022 16:59:14 -0500 (EST) |
branch: elpa/typescript-mode
commit a2167a133dfc7042d931a80c34439f38c06e756d
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>
Fix errors with indentation when line has wide unicode chars.
This closes https://github.com/ananthakumaran/typescript.el/issues/33.
---
typescript-mode-tests.el | 7 +++++++
typescript-mode.el | 9 ++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/typescript-mode-tests.el b/typescript-mode-tests.el
index 0c8fec5076..6e135f8090 100644
--- a/typescript-mode-tests.el
+++ b/typescript-mode-tests.el
@@ -99,6 +99,13 @@ 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 ()
+ "Otsuka Ai and other multi-char users should be a happy to write typescript."
+
+ (with-temp-buffer
+ (insert "大塚愛")
+ (should (equal 3 (typescript-current-column)))))
+
(provide 'typescript-mode-tests)
;;; typescript-mode-tests.el ends here
diff --git a/typescript-mode.el b/typescript-mode.el
index 12c71a9897..f4465495dd 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1795,6 +1795,13 @@ 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."
+
+ (let* ((end (point)))
+ (move-beginning-of-line nil)
+ (- end (point))))
+
(defun typescript-indent-line ()
"Indent the current line as typescript."
(interactive)
@@ -1802,7 +1809,7 @@ nil."
(widen)
(let* ((parse-status
(save-excursion (syntax-ppss (point-at-bol))))
- (offset (- (current-column) (current-indentation))))
+ (offset (- (typescript-current-column) (current-indentation))))
(indent-line-to (typescript--proper-indentation parse-status))
(when (> offset 0) (forward-char offset)))))
- [nongnu] elpa/typescript-mode 8fe879a96d 028/222: Support 'of' keyword., (continued)
- [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, 2022/02/06
- [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 <=
- [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
- [nongnu] elpa/typescript-mode bd046e0fae 120/222: Add tags in usejsdoc.org, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 3c79132066 136/222: fix warnings from package-lint, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 000131df29 150/222: Update CI-settings, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b1d1948c15 123/222: Merge pull request #88 from Ptival/fix-indentation-method-calls-keywords, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 039d122384 156/222: add a test for simple tsx, ELPA Syncer, 2022/02/06