branch: externals/sql-indent
commit 1cba9fbea92524f31ec23d752f774c8f2167a87b
Author: Alex Harsanyi <[email protected]>
Commit: Alex Harsanyi <[email protected]>
fixup refining a nested-statement-continuation (#46)
when the nested statement continuation had a comment at the start, any
select
statements inside it were missed.
---
sql-indent-test.el | 3 +++
sql-indent.el | 2 +-
test-data/pr46-syn.eld | 20 ++++++++++++++++++++
test-data/pr46.sql | 8 ++++++++
4 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/sql-indent-test.el b/sql-indent-test.el
index adf6e08..6e5a0bc 100644
--- a/sql-indent-test.el
+++ b/sql-indent-test.el
@@ -342,4 +342,7 @@ information read from DATA-FILE (as generated by
(ert-deftest sqlind-ert-pr42 ()
(sqlind-ert-check-file-syntax "test-data/pr42.sql" "test-data/pr42-syn.eld"))
+(ert-deftest sqlind-ert-pr46 ()
+ (sqlind-ert-check-file-syntax "test-data/pr46.sql" "test-data/pr46-syn.eld"))
+
;;; sql-indent-test.el ends here
diff --git a/sql-indent.el b/sql-indent.el
index d4d6c2c..bd12c8b 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -1219,7 +1219,7 @@ not a statement-continuation POS is the same as the
(goto-char anchor)
(when (eq syntax 'nested-statement-continuation)
(forward-char 1)
- (skip-chars-forward " \t\r\n\f\v")
+ (sqlind-forward-syntactic-ws)
(setq anchor (point)))
;; when all we have before `pos' is a label, we have a
diff --git a/test-data/pr46-syn.eld b/test-data/pr46-syn.eld
new file mode 100644
index 0000000..975e96b
--- /dev/null
+++ b/test-data/pr46-syn.eld
@@ -0,0 +1,20 @@
+(((toplevel . 1))
+ ((comment-start . 20)
+ (nested-statement-open . 20)
+ (statement-continuation . 20))
+ ((nested-statement-continuation . 20)
+ (statement-continuation . 20))
+ ((select-column . 52)
+ (nested-statement-continuation . 20)
+ (statement-continuation . 20))
+ ((select-column . 52)
+ (nested-statement-continuation . 20)
+ (statement-continuation . 20))
+ ((select-clause . 52)
+ (nested-statement-continuation . 20)
+ (statement-continuation . 20))
+ ((with-clause . 1)
+ (statement-continuation . 1))
+ ((select-clause . 115)
+ (statement-continuation . 1))
+ ((toplevel . 1)))
diff --git a/test-data/pr46.sql b/test-data/pr46.sql
new file mode 100644
index 0000000..f18940d
--- /dev/null
+++ b/test-data/pr46.sql
@@ -0,0 +1,8 @@
+with some_table as (
+ -- a comment at the start
+ select col1,
+ col2,
+ col3
+ from some_table)
+select *
+ from some_table;