Skip to content

Fix problems with error on the first command of a file. #816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion ci/coq-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,47 @@ For example, COMMENT could be (*test-definition*)"
(coq-test-goto-before "(*proof*)")
(backward-char 3)
(should (span-at (point) 'proofusing))))))




(ert-deftest 110_coq-test-regression_error_on_fst_cmd ()
"Test error highlghting in the first line."
(coq-fixture-on-file
(coq-test-full-path "test_error_loc_fst_cmd.v")
(lambda ()
(coq-test-goto-before " (*after-error*)")
;; redefining this function locally so that self removing spans
;; remain longer. Cf span.el
(cl-letf (((symbol-function 'span-make-self-removing-span)
(lambda (beg end &rest props)
(let ((ol (span-make beg end)))
(while props
(overlay-put ol (car props) (cadr props))
(setq props (cddr props)))
(add-timeout 10 'delete-overlay ol)
ol))))

(let ((proof-cmd-point (save-excursion
(coq-test-goto-before "(*after-error*)")
(re-search-backward "bar"))))
(coq-test-goto-after " (*after-error*)")
(proof-goto-point)
(proof-shell-wait)
(coq-should-buffer-string "Error: The reference bar was not found in the current environment.")
;; checking that there is an overlay with warning face
;; exactly on "bar". WARNING: this overlay lasts only for 12
;; secs (thx to the add-timeout above), if this test is done
;; in a (very) slow virtual machine this may fail.
(should (equal (point) proof-cmd-point))
(let ((sp (span-at proof-cmd-point 'face)))
(should sp)
(should (equal (span-property sp 'face) 'proof-warning-face))
(should (equal (span-start sp) proof-cmd-point))
;; coq-8.11 used to hace ending ps shifted by one
(should (or (equal (span-end sp) (+ proof-cmd-point (length "bar")))
(equal (span-end sp) (+ 1 proof-cmd-point (length "bar")))))
)
(should (equal (proof-queue-or-locked-end) (point-min))))))))
(provide 'coq-tests)

;;; coq-tests.el ends here
4 changes: 4 additions & 0 deletions ci/test_error_loc_fst_cmd.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Definition foo:= bar. (*after-error*)

Definition foobar := nat.

3 changes: 2 additions & 1 deletion coq/coq-indent.el
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ position."
(while (coq-looking-at-comment) ;; we are looking for ". " so this is enough
(re-search-backward (concat "\\(?2:" coq-simple-cmd-ender-prefix-regexp-backward "\\)\\.\\s-") (point-min) 'dummy))
;; unless we reached point-min, jump over the "."
(when (match-end 2) (goto-char (match-end 2)) (forward-char 1))
(when (and (not (eq (point) (point-min))) (match-end 2))
(goto-char (match-end 2)) (forward-char 1))
(point))

(defun coq-find-start-of-cmd ()
Expand Down
Loading