emacs-elpa-diffs
[Top][All Lists]
Advanced

[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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]