[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/sql-indent 5a66deef3b 1/2: Fix syntax identification fo
From: |
Stefan Monnier |
Subject: |
[elpa] externals/sql-indent 5a66deef3b 1/2: Fix syntax identification for "end if" blocks (#102) |
Date: |
Wed, 5 Jan 2022 18:35:02 -0500 (EST) |
branch: externals/sql-indent
commit 5a66deef3bbb5ac5d3386a26cda13f255bc6b46d
Author: Alex Harsányi <AlexHarsanyi@gmail.com>
Commit: Alex Harsányi <AlexHarsanyi@gmail.com>
Fix syntax identification for "end if" blocks (#102)
---
sql-indent-test.el | 5 +++++
sql-indent.el | 3 ++-
test-data/pr102-syn.eld | 14 ++++++++++++++
test-data/pr102.sql | 5 +++++
4 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/sql-indent-test.el b/sql-indent-test.el
index 266a8bdfd4..3fefe94b4e 100644
--- a/sql-indent-test.el
+++ b/sql-indent-test.el
@@ -483,4 +483,9 @@ information read from DATA-FILE (as generated by
"test-data/pr99.sql"
"test-data/pr99-syn.eld"))
+(ert-deftest sqlind-ert-pr102 ()
+ (sqlind-ert-check-file-syntax
+ "test-data/pr102.sql"
+ "test-data/pr102-syn.eld"))
+
;;; sql-indent-test.el ends here
diff --git a/sql-indent.el b/sql-indent.el
index e3503d7686..cfd0e4a0ab 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -1626,7 +1626,8 @@ not a statement-continuation POS is the same as the
(push (cons (list 'block-start 'exception) anchor) context))
((and (eq syntax-symbol 'in-block)
- (memq (nth 1 syntax) '(then case)))
+ (memq (nth 1 syntax) '(then case))
+ (not (looking-at "end\\s-*\\_<\\(if\\|case\\)\\_>")))
(if (looking-at "when\\_>")
(push (cons (list 'block-start 'when) anchor) context)
;; NOTE: the "when" case is handed above
diff --git a/test-data/pr102-syn.eld b/test-data/pr102-syn.eld
new file mode 100644
index 0000000000..ec7b5c9013
--- /dev/null
+++ b/test-data/pr102-syn.eld
@@ -0,0 +1,14 @@
+(((toplevel . 1))
+ (((block-start then)
+ . 1)
+ ((in-block if "")
+ . 1))
+ (((in-block then "")
+ . 16))
+ (((in-block then "")
+ . 16))
+ (((block-end if "")
+ . 16)
+ ((in-block then "")
+ . 16))
+ ((toplevel . 1)))
\ No newline at end of file
diff --git a/test-data/pr102.sql b/test-data/pr102.sql
new file mode 100644
index 0000000000..dcd5dd6781
--- /dev/null
+++ b/test-data/pr102.sql
@@ -0,0 +1,5 @@
+if (not found)
+then
+ raise notice 'Not found';
+ return 1;
+end if;