From 6335387304d0f66cbc89527027d0637a27143416 Mon Sep 17 00:00:00 2001 From: Benj Date: Sun, 15 Jan 2023 13:05:14 +0100 Subject: [PATCH 1/2] cider--goto-expression-start: Do not throw if bop --- cider-eval.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cider-eval.el b/cider-eval.el index 29ce15156..0b3ef76da 100644 --- a/cider-eval.el +++ b/cider-eval.el @@ -602,8 +602,10 @@ until we find a delimiters that's not inside a string." (if (and (looking-back "[])}]" (line-beginning-position)) (null (nth 3 (syntax-ppss)))) (backward-sexp) - (while (or (not (looking-at-p "[({[]")) - (nth 3 (syntax-ppss))) + (while (and (not (bobp)) + (or + (not (looking-at-p "[({[]")) + (nth 3 (syntax-ppss)))) (backward-char)))) (defun cider--find-last-error-location (message) From e5294636ddc188949ab6de4b0fb3880411730073 Mon Sep 17 00:00:00 2001 From: Benj Date: Wed, 1 Feb 2023 12:13:01 +0100 Subject: [PATCH 2/2] Add a test for cider--goto-expression-start --- test/cider-eval-test.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/cider-eval-test.el b/test/cider-eval-test.el index 90662d0cd..382231e7a 100644 --- a/test/cider-eval-test.el +++ b/test/cider-eval-test.el @@ -47,4 +47,23 @@ (insert "🍻")) (expect (cider-provide-file filename) :to-equal "8J+Nuw==")))) +(describe + "cider--goto-expression-start" + (it "Does not throw an error, when file does not contain a list" + (expect + (with-temp-buffer + (insert "foo") + ;; After evaling, message: + ;; "Syntax error compiling at (foo.clj:0:0). + ;; Unable to resolve symbol: foo in this context + ;; " + ;; cider--find-last-error-location goes to location + ;; 0:0 and calls cider--goto-expression-start + (goto-char (point-min)) + ;; no error + (cider--goto-expression-start) + 'ok) + :to-equal 'ok))) + + (provide 'cider-eval-tests)