[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit ceec6a63b0 236/244: better algorithm to match
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit ceec6a63b0 236/244: better algorithm to match bracket/brace in javascript |
Date: |
Thu, 6 Jan 2022 02:59:05 -0500 (EST) |
branch: elpa/evil-matchit
commit ceec6a63b014da874c9b6b6b0174592c93b4e12b
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
better algorithm to match bracket/brace in javascript
---
evil-matchit-javascript.el | 6 ++++--
tests/evil-matchit-tests.el | 24 ++++++++++++++++++++++++
tests/hello.js | 11 ++++++++++-
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/evil-matchit-javascript.el b/evil-matchit-javascript.el
index 28a965728f..901a6306cd 100644
--- a/evil-matchit-javascript.el
+++ b/evil-matchit-javascript.el
@@ -45,7 +45,8 @@
;; React JS code: " return ("
;; line could ends with C++ or C comment
(defvar evilmi-javascript-open-brace-pattern
- "^[ \t]*[(}]?[$_a-zA-Z0-9]+.*\\([{(]\\)[ \t]*\\(\/\/.*\\|\/\*[^/]*\*\/\\)?$")
+ "^[ \t]*[(}]?[$_a-zA-Z0-9]+.*\\([{(\[]\\)[
\t]*\\(\/\/.*\\|\/\*[^/]*\*\/\\)?$"
+ "Pattern to match line which ends with brace or bracket character.")
(defun evilmi--javascript-find-open-brace (cur-line)
"Find open brace from CUR-LINE."
@@ -54,6 +55,7 @@
((string-match evilmi-javascript-open-brace-pattern
cur-line)
(setq rlt (list 1 (match-string 1 cur-line))))
+
(t
(save-excursion
(forward-line)
@@ -94,7 +96,7 @@
"Jump to the matching tag using INFO and NUM."
(cond
((not info)
- ;; don nothing
+ ;; do nothing
)
((evilmi-sdk-get-tag evilmi-javascript-match-tags
evilmi-javascript-extract-keyword-howtos)
diff --git a/tests/evil-matchit-tests.el b/tests/evil-matchit-tests.el
index 3f02c81b93..a16abd6365 100644
--- a/tests/evil-matchit-tests.el
+++ b/tests/evil-matchit-tests.el
@@ -108,6 +108,30 @@
(evilmi-jump-items)
(should (eq (point) beg)))
+ (search-forward "test1" (point-max) t)
+ (backward-word)
+ (should (string= (evilmi-sdk-curline) "const test1 = ["))
+ (evilmi-jump-items)
+ (should (string= (evilmi-sdk-curline) "];"))
+ (evilmi-jump-items)
+ (should (string= (evilmi-sdk-curline) "const test1 = ["))
+
+ (search-forward "test2" (point-max) t)
+ (backward-word)
+ (should (string= (evilmi-sdk-curline) "const test2 = {"))
+ (evilmi-jump-items)
+ (should (string= (evilmi-sdk-curline) "};"))
+ (evilmi-jump-items)
+ (should (string= (evilmi-sdk-curline) "const test2 = {"))
+
+ (search-forward "test3" (point-max) t)
+ (backward-word)
+ (should (string= (evilmi-sdk-curline) "const test3 = hello("))
+ (evilmi-jump-items)
+ (should (string= (evilmi-sdk-curline) ");"))
+ (evilmi-jump-items)
+ (should (string= (evilmi-sdk-curline) "const test3 = hello("))
+
(should (eq major-mode 'js-mode))))
(ert-deftest evilmi-test-html ()
diff --git a/tests/hello.js b/tests/hello.js
index 73955f05bc..7eecc3ff42 100644
--- a/tests/hello.js
+++ b/tests/hello.js
@@ -1,3 +1,12 @@
function hello() {
console.log('hello world');
-}
\ No newline at end of file
+}
+
+const test1 = [
+];
+
+const test2 = {
+};
+
+const test3 = hello(
+);
\ No newline at end of file
- [nongnu] elpa/evil-matchit e941c695f3 173/244: Add [ and { as well., (continued)
- [nongnu] elpa/evil-matchit e941c695f3 173/244: Add [ and { as well., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit c04f8f480c 164/244: Match Ruby's begin also when it's not on the beginning of the line, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit d779aedaf1 195/244: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit dead63c7d0 194/244: add unit test, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 80dc731ab7 237/244: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0be04f960f 049/244: use text objects v1.3.2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 62cef4f91a 077/244: replace evil-jump-items v2.0, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 6390e9e06c 216/244: Silence byte-compiler, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ae8fddea39 207/244: clean code, tdd for markdown, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0fd65c463b 226/244: clean code&doc, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ceec6a63b0 236/244: better algorithm to match bracket/brace in javascript,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit 8c4f516265 238/244: Support matlab-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 82c80786e5 240/244: jump between merge conflict markers, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 5c43939d01 212/244: Merge pull request #126 from neojski/more-ocaml-tests, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit cdb9b90381 229/244: extra json support, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit d005e0465e 223/244: Merge pull request #130 from nbfalcon/bugfix/evilmi-sdk-simple-jump-whitespace, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ce90eae4bd 243/244: typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit a0c5bd1fe8 230/244: support quote and export section in org file, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9cdaddd55d 228/244: Merge pull request #132 from aaronjensen/require-evil-macros, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8b71b42603 041/244: better support for sh and c/c++ v1.2.8, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4846518b59 109/244: support rjsx-mode, ELPA Syncer, 2022/01/06