clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.54k stars 645 forks source link

The cider-error-hoover overlay gets applied to random logging statements in the REPL #3539

Closed lassemaatta closed 11 months ago

lassemaatta commented 11 months ago

Expected behavior

Accidentally clicking on a line in the REPL should not open dired :sweat_smile:

Actual behavior

The logging framework (com.taoensso/timbre) of our app logs stuff in the REPL. Sometimes, some subsegments of these log lines get the cider-error-hoover overlay. If you accidentally click on such line segment, a dired buffer opens in the project root folder.

Full line in the REPL:

DEBUG 2023-10-18 14:40:28.101 [962fe21b-a87d-4cfa-afc8-b64556de155d] [] [] lupapalvelu.perf-mon - /api/query/comments : 4 ms, 1 db calls took totally 2 ms

The section of the above line which acts as a link:

DEBUG 2023-10-18 14:40:28.101 [962fe21b-a87d-4cfa-afc8-b64556de155d] [] [] lupapalvelu.perf-mon - /api/query/comments : 4

In other words, the rest of the line (ms, 1 db calls took totally 2 ms) does not get the overlay and does not act as a link.

The describe-text-properties on such a line segment produces.

Text content at position 67056:

There are 2 overlays here:
 From 67007 to 67128
  category             cider-error-hoover
  follow-link          mouse
  keymap               [Show]
  mouse-face           highlight
  pointer              hand
 From 67007 to 67162
  face                 hl-line
  priority             -50
  window               [Show]

There are text properties here:
  font-lock-face       cider-repl-stdout-face
  fontified            t
  help-echo            cider-locref-help-echo
  rear-nonsticky       (font-lock-face)

[back]

Steps to reproduce the problem

Hard to say. I think this might have something to do with the [] [] segment of the line. I think that this problem only affects lines which contain that part.

Environment & Version information

CIDER version information

;; CIDER 1.8.3-snapshot (package: 1.8.2), nREPL 1.1.0-alpha1
;; Clojure 1.10.3, Java 17.0.8.1

Lein / Clojure CLI version

Leiningen 2.10.0 on Java 17.0.8.1 OpenJDK 64-Bit Server VM

Emacs version

GNU Emacs 29.1.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0) of 2023-09-30

Operating system

Arch Linux

JDK distribution

openjdk version "17.0.8.1" 2023-08-24
OpenJDK Runtime Environment (build 17.0.8.1+1)
OpenJDK 64-Bit Server VM (build 17.0.8.1+1, mixed mode)
vemv commented 11 months ago

Thanks!

We haven't touched this area in quite a while I believe, so probably you have found a corner case.

Regardless, it's worth fixing and I'll be looking into it.

vemv commented 11 months ago

I fixed what I consider to be the main issue, namely that we could try jumping to non-existing files (mislead from bad regex matches)

For those cases we'll throw a (error) as usual for this section of the code. If it turns out to be annoying on click, LMK, although it shouldn't.

The regexes themselves are controlled by the cider-locref-regexp-alist. If you'd want the clicking to work, you'd need to tweak them. From our side it would seem rather low-prio at given that:

Cheers - V

lassemaatta commented 11 months ago

Great, thanks!

If you'd want the clicking to work

Speaking for myself, I'd rather just disable the clicking. I often have the REPL buffer open and when switching back to emacs from e.g. the browser by clicking (yes, I use the mouse, please don't hate me) on the emacs window, I would often accidentally click on one of these overlay lines in the REPL which would a) move the focus to emacs, b) open dired, and c) leave me confused :)

vemv commented 11 months ago

You can always set cider-locref-regexp-alist to nil. Perhaps you'd want that only for remote projects - the clicking behavior seems generally useful.