[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/sql-indent e7e7e85 11/13: Don't recognize select keywor
From: |
Alex Harsanyi |
Subject: |
[elpa] externals/sql-indent e7e7e85 11/13: Don't recognize select keywords in comments, fixes #83 |
Date: |
Thu, 20 Jun 2019 05:25:47 -0400 (EDT) |
branch: externals/sql-indent
commit e7e7e855a550773aba99fa50675a753038c11f0d
Author: Alex Harsanyi <address@hidden>
Commit: Alex Harsanyi <address@hidden>
Don't recognize select keywords in comments, fixes #83
when searching for select keywords for anchors, don't stop inside comments
--
this just uses `sqlind-search-backward`, which makes sure that the position
that is found is at the same level as the starting position.
Also fixed a bug in `sqlind-same-level-statement` which missed that the
anchor
was inside a comment.
---
sql-indent-test.el | 5 +++++
sql-indent.el | 4 ++--
test-data/pr83-syn.eld | 15 +++++++++++++++
test-data/pr83.sql | 7 +++++++
4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/sql-indent-test.el b/sql-indent-test.el
index c95590d..9705929 100644
--- a/sql-indent-test.el
+++ b/sql-indent-test.el
@@ -407,4 +407,9 @@ information read from DATA-FILE (as generated by
"test-data/pr81.sql"
"test-data/pr81-syn.eld"))
+(ert-deftest sqlind-ert-pr83 ()
+ (sqlind-ert-check-file-syntax
+ "test-data/pr83.sql"
+ "test-data/pr83-syn.eld"))
+
;;; sql-indent-test.el ends here
diff --git a/sql-indent.el b/sql-indent.el
index d9d27af..454c25e 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -168,7 +168,7 @@ a string or comment."
(let ((ppss-point (syntax-ppss point))
(ppss-start (syntax-ppss start)))
(and (equal (nth 3 ppss-point) (nth 3 ppss-start)) ; string
- (equal (nth 4 ppss-start) (nth 4 ppss-start)) ; comment
+ (equal (nth 4 ppss-point) (nth 4 ppss-start)) ; comment
(= (nth 0 ppss-point) (nth 0 ppss-start)))))) ; same nesting
(defun sqlind-column-definition-start (pos limit)
@@ -1036,7 +1036,7 @@ reverse order (a stack) and is used to skip over nested
blocks."
;; when we are not looking at a select component, find the
;; nearest one from us.
- (while (re-search-backward sqlind-select-clauses-regexp start t)
+ (while (sqlind-search-backward (point) sqlind-select-clauses-regexp
start)
(let* ((match-pos (match-beginning 0))
(clause (sqlind-match-string 0)))
(setq clause (replace-regexp-in-string "[ \t\r\n\f]" " " clause))
diff --git a/test-data/pr83-syn.eld b/test-data/pr83-syn.eld
new file mode 100644
index 0000000..7251537
--- /dev/null
+++ b/test-data/pr83-syn.eld
@@ -0,0 +1,15 @@
+(((toplevel . 1))
+ ((select-column . 1)
+ (statement-continuation . 1))
+ ((select-column . 1)
+ (statement-continuation . 1))
+ ((comment-start . 1)
+ (statement-continuation . 1))
+ ((select-column . 1)
+ (statement-continuation . 1))
+ ((select-column . 1)
+ (statement-continuation . 1))
+ ((select-clause . 1)
+ (statement-continuation . 1))
+ ((toplevel . 1)))
+
\ No newline at end of file
diff --git a/test-data/pr83.sql b/test-data/pr83.sql
new file mode 100644
index 0000000..32a73a6
--- /dev/null
+++ b/test-data/pr83.sql
@@ -0,0 +1,7 @@
+SELECT
+ Column1,
+ Column2,
+ -- this is FROM a blog WHERE useful stuff was described
+ Column3,
+ Column4
+ FROM Atable;
- [elpa] externals/sql-indent updated (87a6b4a -> 47e9ccb), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 9d5f978 05/13: Fix regexp bug in `sqlind-good-if-candidate` (fixes #76), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 31c29ed 12/13: Recognize more types of begin transaction statements (fixes #84), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 2ca9610 09/13: don't be confused by drop function or procedure statements #80, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent f897c11 08/13: Apply advices of `checkdoc' (#77), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent dccd194 02/13: Recognize `select-join-condition` syntax inside nested statements #70 (#71), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent e7e7e85 11/13: Don't recognize select keywords in comments, fixes #83,
Alex Harsanyi <=
- [elpa] externals/sql-indent 47e9ccb 13/13: Recognize left and right outer join statements #85, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent e511ced 01/13: `sqlind-search-backward` finds things at the same nesting level (#68) (#69), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent d9442ed 03/13: Recognize FULL JOIN, UNION ALL and EXCEPT keywords #73 (#74), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 1974564 10/13: recognize elseif in addition to elif #81, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 9559ebe 07/13: Fix `sqlind-comment-end' regexp. (#79), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent ba2a690 06/13: also fix sqlind-end-statement-regexp, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent a6da8bd 04/13: Recognize more create keywords (#75), Alex Harsanyi, 2019/06/20