Skip to content

Commit e78d678

Browse files
vspinubbatsov
authored andcommitted
Don't attempt to recover srcloc under point on long lines
1 parent 5435c67 commit e78d678

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
* [#2430](https://github.com/clojure-emacs/cider/issues/2375): `cider-find-var` opens archive files inside [AVFS](http://avf.sourceforge.net) folders if AVFS is detected.
2222
* [#2446](https://github.com/clojure-emacs/cider/issues/2446): Implement Sesman friendly sessions to allow for on-the-fly association with sessions from dependency projects and jars.
2323
* [#2253](https://github.com/clojure-emacs/cider/issues/2253): Split `continue` debug command into "continue till next breakpoint" (`c`) and "continue non stop" (`C`) commands.
24+
* Add support for CompilationException dynamic source location discovery.
2425

2526
### Bug fixes
2627

28+
* Fix re-display hangs while dynamically recovering source locations under mouse pointer.
2729
* [#2474](https://github.com/clojure-emacs/cider/issues/2474): Fix incorrect detection of output and out-of-order printing.
2830
* [#2514](https://github.com/clojure-emacs/cider/issues/2514): Don't auto-jump to warnings when `cider-auto-jump-to-error` is set to 'errors-only.
2931
* [#2453](https://github.com/clojure-emacs/cider/issues/2453): Make it possible to debug deftype methods by direct insertion of #dbg and #break readers into the deftype methods.

cider-repl.el

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,27 +1177,24 @@ case."
11771177
:group 'cider-repl
11781178
:package-version '(cider. "0.16.0"))
11791179

1180-
(defun cider--locref-at-point-1 (reg-list &optional pos)
1181-
"Workhorse for getting locref at POS.
1180+
(defun cider--locref-at-point-1 (reg-list)
1181+
"Workhorse for getting locref at point.
11821182
REG-LIST is an entry in `cider-locref-regexp-alist'."
1183-
(save-excursion
1184-
(let ((pos (or pos (point))))
1185-
(goto-char pos)
1186-
(beginning-of-line)
1187-
(when (re-search-forward (nth 1 reg-list) (point-at-eol) t)
1188-
(let ((ix-highlight (or (nth 2 reg-list) 0))
1189-
(ix-var (nth 3 reg-list))
1190-
(ix-file (nth 4 reg-list))
1191-
(ix-line (nth 5 reg-list)))
1192-
(list
1193-
:type (car reg-list)
1194-
:highlight (cons (match-beginning ix-highlight) (match-end ix-highlight))
1195-
:var (and ix-var
1196-
(replace-regexp-in-string "_" "-"
1197-
(match-string-no-properties ix-var)
1198-
nil t))
1199-
:file (and ix-file (match-string-no-properties ix-file))
1200-
:line (and ix-line (string-to-number (match-string-no-properties ix-line)))))))))
1183+
(beginning-of-line)
1184+
(when (re-search-forward (nth 1 reg-list) (point-at-eol) t)
1185+
(let ((ix-highlight (or (nth 2 reg-list) 0))
1186+
(ix-var (nth 3 reg-list))
1187+
(ix-file (nth 4 reg-list))
1188+
(ix-line (nth 5 reg-list)))
1189+
(list
1190+
:type (car reg-list)
1191+
:highlight (cons (match-beginning ix-highlight) (match-end ix-highlight))
1192+
:var (and ix-var
1193+
(replace-regexp-in-string "_" "-"
1194+
(match-string-no-properties ix-var)
1195+
nil t))
1196+
:file (and ix-file (match-string-no-properties ix-file))
1197+
:line (and ix-line (string-to-number (match-string-no-properties ix-line)))))))
12011198

12021199
(defun cider-locref-at-point (&optional pos)
12031200
"Return a plist of components of the location reference at POS.
@@ -1206,8 +1203,13 @@ found. Returned keys are :type, :highlight, :var, :file, :line, where
12061203
:highlight is a cons of positions, :var and :file are strings or nil, :line
12071204
is a number. See `cider-locref-regexp-alist' for how to specify regexes
12081205
for locref look up."
1209-
(seq-some (lambda (rl) (cider--locref-at-point-1 rl pos))
1210-
cider-locref-regexp-alist))
1206+
(save-excursion
1207+
(goto-char (or pos (point)))
1208+
;; Regexp lookup on long lines can result in significant hangs #2532. We
1209+
;; assume that lines longer than 300 don't contain source references.
1210+
(when (< (- (point-at-eol) (point-at-bol)) 300)
1211+
(seq-some (lambda (rl) (cider--locref-at-point-1 rl))
1212+
cider-locref-regexp-alist))))
12111213

12121214
(defun cider-jump-to-locref-at-point (&optional pos)
12131215
"Identify location reference at POS and navigate to it.

test/cider-repl-tests.el

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,6 @@ PROPERTY shoudl be a symbol of either 'text, 'ansi-context or
204204
(expect (cider-locref-at-point)
205205
:to-equal
206206
'(:type cljs-message :highlight (54 . 86) :var nil :file "/path/to/aaa/bbb.cljc" :line 42))))
207-
(it "works with warnings"
208-
(with-temp-buffer
209-
(insert "\nReflection warning, cider/nrepl/middleware/slurp.clj:103:16 - reference to field getInputStream can't be resolved.")
210-
(move-to-column 20)
211-
(expect (cider-locref-at-point)
212-
:to-equal
213-
'(:type warning :highlight (22 . 61) :var nil :file "cider/nrepl/middleware/slurp.clj" :line 103))))
214207
(it "works with warnings"
215208
(with-temp-buffer
216209
(insert "\nReflection warning, cider/nrepl/middleware/slurp.clj:103:16 - reference to field getInputStream can't be resolved.")

0 commit comments

Comments
 (0)