Skip to content
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

Try fixing a bug in apropos #130

Merged
merged 1 commit into from
Sep 27, 2021
Merged

Try fixing a bug in apropos #130

merged 1 commit into from
Sep 27, 2021

Conversation

vemv
Copy link
Member

@vemv vemv commented Sep 24, 2021

See #128

Tries fixing the bug itself, and also introduces a fallback. Will comment inline.

(defn- default-comparator [ns clojure-ns?]
(fn [x y]
(cond
(= x y) 0
Copy link
Member Author

@vemv vemv Sep 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a (= x y) 0 clause making the sort stable.

Unfortunately I couldn't prove this fixes the issue, however it's most likely an improvement.

;; Don't accept this exception in our CI - we should fix this if it's reproducible.
(throw e))
;; Fallback to a simpler comparator:
(sort-by key-fn safe-comparator vars)))))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a fallback so that this feature doesn't fail altogether due to something relatively unimportant such as sorting.

[orchard.meta :refer [var-name var-doc]]))

(def ^{:doc "Test1. Test2. Test3."} public-var [1 2 3])

(defn some-random-function [])

(deftest apropos-sort-test
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some extra tests, they passed before the fix anyway.

#128 seems hard to repro since apropos results depend on ones's classpath.

@bbatsov bbatsov merged commit 97e6538 into master Sep 27, 2021
@bbatsov
Copy link
Member

bbatsov commented Sep 27, 2021

The proposed fix seems good to me.

@bbatsov bbatsov deleted the 128 branch September 27, 2021 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants