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) 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)