Skip to content

Commit

Permalink
[Fix #2721] Handle properly symbols ending in . (e.g. SomeRecord.)
Browse files Browse the repository at this point in the history
Now `cider-symbol-at-point` simply rejects the trailing dot.
  • Loading branch information
bbatsov committed Oct 6, 2019
1 parent 6f0f25b commit fd1f62e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* [#2705](https://github.com/clojure-emacs/cider/issues/2705): Middleware version check looks at only at the minor version for comparison (when the major version is 0) and ensures a matching major and a minor >= required otherwise.
* Fixed some bugs related to the new suitable-powered ClojureScript code completion (this was fixed by upgrading the `suitable` used by `cider-nrepl`).
* Remove a misplaced error message when doing `clojuredocs-lookup`.
* [#2721](https://github.com/clojure-emacs/cider/issues/2721): Handle properly symbols ending in `.` (e.g. `SomeRecord.`).

## 0.22.0 (2019-09-01)

Expand Down
3 changes: 2 additions & 1 deletion cider-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ Ignores the REPL prompt. If LOOK-BACK is non-nil, move backwards trying to
find a symbol if there isn't one at point."
(or (when-let* ((str (thing-at-point 'symbol)))
(unless (text-property-any 0 (length str) 'field 'cider-repl-prompt str)
(substring-no-properties str)))
;; Remove font-locking and trailing . from constructors like Record.
(string-trim-right (substring-no-properties str) "\\.")))
(when look-back
(save-excursion
(ignore-errors
Expand Down
7 changes: 7 additions & 0 deletions test/cider-util-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@
(expect (cider-symbol-at-point) :not :to-be-truthy)
(expect (cider-symbol-at-point 'look-back) :to-equal "some-symbol"))))

(describe "when the symbol at point has a trailing ."
(it "returns the symbol without the ."
(with-temp-buffer
(insert "SomeRecord.")
(expect (cider-symbol-at-point) :not :to-be-truthy)
(expect (cider-symbol-at-point 'look-back) :to-equal "SomeRecord"))))

(describe "when there's nothing at point"
(it "returns nil"
(spy-on 'thing-at-point :and-return-value nil)
Expand Down

0 comments on commit fd1f62e

Please sign in to comment.