@@ -764,7 +764,8 @@ and ON-SUCCESS-CALLBACK an optional callback.
764
764
The handler simply inserts the result value in BUFFER."
765
765
(let ((eval-buffer (current-buffer ))
766
766
(res " " )
767
- (failed nil ))
767
+ (failed nil )
768
+ (error-phase-requested nil )) ; ; avoid requesting the phase more than once - can happen if there are errors during the phase nrepl sync request.
768
769
(nrepl-make-response-handler (or buffer eval-buffer)
769
770
; ; value handler:
770
771
(lambda (_buffer value )
@@ -781,7 +782,10 @@ The handler simply inserts the result value in BUFFER."
781
782
(when (and source-buffer
782
783
(listp bounds)) ; ; if it's a list, it represents bounds, otherwise it's a string (code) and we can't display the overlay
783
784
(with-current-buffer source-buffer
784
- (let* ((phase (cider--error-phase-of-last-exception buffer))
785
+ (let* ((phase (if error-phase-requested
786
+ nil
787
+ (setq error-phase-requested t )
788
+ (cider--error-phase-of-last-exception buffer)))
785
789
(end (or (car-safe (cdr-safe bounds)) bounds))
786
790
(end (when end
787
791
(copy-marker end))))
@@ -845,12 +849,16 @@ REPL buffer. This is controlled via
845
849
(when-let ((conn (with-current-buffer buffer
846
850
(cider-current-repl))))
847
851
(when (cider-nrepl-op-supported-p " analyze-last-stacktrace" conn)
848
- (when-let* ((result (nrepl-send-sync-request (thread-last (map-merge 'list
849
- '((" op" " analyze-last-stacktrace" ))
850
- (cider--nrepl-print-request-map fill-column))
851
- (seq-mapcat #'identity ))
852
- conn)))
853
- (nrepl-dict-get result " phase" ))))))
852
+ (let ((nrepl-err-handler (lambda (&rest _ ))) ; ; ignore any errors during this request to avoid any recursion
853
+ (nrepl-sync-request-timeout 4 )) ; ; ensure that this feature cannot possibly create an overly laggy UX
854
+ (when-let* ((result (nrepl-send-sync-request (thread-last (map-merge 'list
855
+ '((" op" " analyze-last-stacktrace" ))
856
+ (cider--nrepl-print-request-map fill-column))
857
+ (seq-mapcat #'identity ))
858
+ conn
859
+ 'abort-on-input ; ; favor responsiveness over this feature, in case something went wrong.
860
+ )))
861
+ (nrepl-dict-get result " phase" )))))))
854
862
855
863
(defcustom cider-inline-error-message-function #'cider--shorten-error-message
856
864
" A function that will shorten a given error message,
@@ -905,17 +913,24 @@ when `cider-auto-inspect-after-eval' is non-nil."
905
913
(beg (when beg (copy-marker beg)))
906
914
(end (when end (copy-marker end)))
907
915
(fringed nil )
908
- (res " " ))
916
+ (res " " )
917
+ (error-phase-requested nil )) ; ; avoid requesting the phase more than once - can happen if there are errors during the phase nrepl sync request.
909
918
(nrepl-make-response-handler (or buffer eval-buffer)
919
+ ; ; value handler:
910
920
(lambda (_buffer value )
911
921
(setq res (concat res value))
912
922
(cider--display-interactive-eval-result res 'value end))
923
+ ; ; stdout handler:
913
924
(lambda (_buffer out )
914
925
(cider-emit-interactive-eval-output out))
926
+ ; ; stderr handler:
915
927
(lambda (buffer err )
916
928
(cider-emit-interactive-eval-err-output err)
917
929
918
- (let ((phase (cider--error-phase-of-last-exception buffer)))
930
+ (let ((phase (if error-phase-requested
931
+ nil
932
+ (setq error-phase-requested t )
933
+ (cider--error-phase-of-last-exception buffer))))
919
934
920
935
(cider--maybe-display-error-as-overlay phase err end)
921
936
@@ -927,6 +942,7 @@ when `cider-auto-inspect-after-eval' is non-nil."
927
942
; ; the error is 'right there' in the current line
928
943
; ; and needs no jumping:
929
944
phase)))
945
+ ; ; done handler:
930
946
(lambda (buffer )
931
947
(if beg
932
948
(unless fringed
@@ -946,7 +962,8 @@ when `cider-auto-inspect-after-eval' is non-nil."
946
962
" Make a load file handler for BUFFER.
947
963
Optional argument DONE-HANDLER lambda will be run once load is complete."
948
964
(let ((eval-buffer (current-buffer ))
949
- (res " " ))
965
+ (res " " )
966
+ (error-phase-requested nil )) ; ; avoid requesting the phase more than once - can happen if there are errors during the phase nrepl sync request.
950
967
(nrepl-make-response-handler (or buffer eval-buffer)
951
968
(lambda (buffer value )
952
969
(cider--display-interactive-eval-result value 'value )
@@ -963,7 +980,10 @@ Optional argument DONE-HANDLER lambda will be run once load is complete."
963
980
; ; 1.- Jump to the error line:
964
981
(cider-handle-compilation-errors err eval-buffer)
965
982
(with-current-buffer eval-buffer
966
- (let* ((phase (cider--error-phase-of-last-exception buffer))
983
+ (let* ((phase (if error-phase-requested
984
+ nil
985
+ (setq error-phase-requested t )
986
+ (cider--error-phase-of-last-exception buffer)))
967
987
; ; 2.- Calculate the overlay position, which is the point (per the previous jump),
968
988
; ; and then end-of-line (for ensuring the overlay will be rendered properly):
969
989
(end (save-excursion
@@ -1072,7 +1092,8 @@ and SOURCE-BUFFER the original buffer
1072
1092
This is used by pretty-printing commands."
1073
1093
; ; NOTE: cider-eval-register behavior is not implemented here for performance reasons.
1074
1094
; ; See https://github.com/clojure-emacs/cider/pull/3162
1075
- (let ((chosen-buffer (or buffer (current-buffer ))))
1095
+ (let ((chosen-buffer (or buffer (current-buffer )))
1096
+ (error-phase-requested nil )) ; ; avoid requesting the phase more than once - can happen if there are errors during the phase nrepl sync request.
1076
1097
(nrepl-make-response-handler
1077
1098
chosen-buffer
1078
1099
; ; value handler:
@@ -1087,7 +1108,10 @@ This is used by pretty-printing commands."
1087
1108
(when (and source-buffer
1088
1109
(listp bounds)) ; ; if it's a list, it represents bounds, otherwise it's a string (code) and we can't display the overlay
1089
1110
(with-current-buffer source-buffer
1090
- (let* ((phase (cider--error-phase-of-last-exception buffer))
1111
+ (let* ((phase (if error-phase-requested
1112
+ nil
1113
+ (setq error-phase-requested t )
1114
+ (cider--error-phase-of-last-exception buffer)))
1091
1115
(end (or (car-safe (cdr-safe bounds)) bounds))
1092
1116
(end (when end
1093
1117
(copy-marker end))))
0 commit comments