[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 78f0e09 260/468: Make sure nested token searches
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 78f0e09 260/468: Make sure nested token searches begin from open-token positions |
Date: |
Thu, 5 Aug 2021 04:58:49 -0400 (EDT) |
branch: elpa/lua-mode
commit 78f0e09565d77938e9974ac3b38b26a75c1fa6d9
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
Make sure nested token searches begin from open-token positions
There's a `(forward-char 1)' in the beginning of
`lua-find-matching-token-word' function to make sure the open-token is
not found repeatedly that may skip 1-character close-token (e.g. ] or })
if it's right after the open counterpart.
For example (| being current point):
- |function() return {} end -> (forward-sexp)
- |function() return {} end -> (forward-char 1)
- f|unction() return {} end -> (re-search-forward indentation-modifier)
- function() return {|} end -> (forward-char 1)
- function() return {}| end
At this point closing curly braces will be matched incorrectly as the
close brace has been skipped unmatched.
---
Makefile | 1 +
lua-mode.el | 1 +
test/generic-test.el | 13 +++++++++++++
3 files changed, 15 insertions(+)
diff --git a/Makefile b/Makefile
index 3702314..2c946fb 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,7 @@ TESTS += test/builtin-font-lock-test.el
TESTS += test/electric-mode-test.el
TESTS += test/indentation-test.el
TESTS += test/strings-and-comments-test.el
+TESTS += test/generic-test.el
default:
@echo version is $(VERSION)
diff --git a/lua-mode.el b/lua-mode.el
index ad10382..6ff8798 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1049,6 +1049,7 @@ TOKEN-TYPE determines where the token occurs on a
statement. open indicates that
(eq match-type 'middle-or-open)
(eq found-type 'middle-or-open)
(eq match-type found-type))
+ (goto-char found-pos)
(lua-find-matching-token-word found-token
search-direction)))
(when maybe-found-pos
diff --git a/test/generic-test.el b/test/generic-test.el
new file mode 100644
index 0000000..148e1a0
--- /dev/null
+++ b/test/generic-test.el
@@ -0,0 +1,13 @@
+(load (concat (file-name-directory (or load-file-name (buffer-file-name)
+ default-directory))
+ "test-helper.el") nil 'nomessage 'nosuffix)
+
+(ert-deftest lua-forward-sexp-curly-braces ()
+ (with-lua-buffer
+ (lua-insert-goto-<>
+ '("local x = <>function() return {{}} end"
+ ""
+ "function foobar() end"))
+ (lua-forward-sexp)
+ (should (looking-back "x = function() return {{}} end"))))
+
- [nongnu] elpa/lua-mode d81c700 466/468: Bump version tag, (continued)
- [nongnu] elpa/lua-mode d81c700 466/468: Bump version tag, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b9a476c 467/468: Merge pull request #194 from phikal/patch-1, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 28155ba 241/468: Update README.md, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 45a881d 243/468: lua-search-documentation: fix 'foo.bar' lookups broken when making '.' punctuation, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode f8a41b8 246/468: Fix cl-lib dependency for Emacs23 tests, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9e200e8 247/468: Fix font-locking of functions with underscores (issue #63), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode bbab5a6 253/468: Don't anchor arglist continuation to block openers, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9d86a22 254/468: Fix indentation error raised if 'else' is on the same line as 'if', Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 2ad2ac8 256/468: lua-imenu-generic-expression add support for local function, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8ff3427 257/468: Merge pull request #65 from guoxx/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 78f0e09 260/468: Make sure nested token searches begin from open-token positions,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 2cdfda7 264/468: Add inferior-test.el with some basic (failing) tests, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d166d5e 267/468: Merge remote-tracking branch 'upstream/master', Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d52e291 270/468: Don't fontify "stdin:N:" stacktrace entries in REPL buffer, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ec1b634 271/468: Bump NEWS, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d4ee03e 278/468: Use syntax-propertize-function if it is available, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode fd0f6ba 280/468: Merge pull request #69 from atomontage/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 694421c 274/468: Add lua-remove-syntax-table-property to syntactic keywords, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b73794f 276/468: Merge pull request #79 from j-fu/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 13f6ffa 277/468: Provide lua--setq-local fallback macro for pre-24.3, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ce0a813 282/468: Mention xristos in AUTHORS, Philip Kaludercic, 2021/08/05