-
Notifications
You must be signed in to change notification settings - Fork 349
Fix haskell-ident-at-point uses and haskell-ident-pos-at-point behavior
#603
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
Conversation
The documentation mandates that `haskell-ident-at-point` return nil when there is no identifier at point; however, apparently, it instead returned `""` in that case at some point, and so some code made faulty assumptions based on that.
The documentation mandates that `haskell-ident-pos-at-point` return nil when there is no identifier at point; however, it instead returned a cons cell of the form `(n . n)`. This is now fixed, and any code that relied on this behavior has been changed. This also therefore fixes `haskell-spanable-pos-at-point` in the same way.
|
Awesome! (: Great job! |
|
Awesome! One more thing: there is a
|
haskell.el
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change:
(when (and (stringp ident) (not (string= "" (haskell-string-trim ident)))into
(when (and ident (not (string= "" (haskell-string-trim ident)))ident should be either nil or string at this point. I would prefer it to crash if it is something else rather than silently swallow wrong type.
As gracjan requested in haskell#603, I > * add[ed] a test case for haskell-ident-at-point really returning nil when it should > * add[ed] a test case for haskell-ident-pos-at-point returning non-nil > * add[ed] a test case for haskell-ident-pos-at-point returning nil > * add[ed] a test case for haskell-spanable-pos-at-point returning non-nil > * add[ed] a test case for haskell-spanable-pos-at-point returning nil I added some somewhat detailed `nil`-checking, a couple quick tests for `haskell-{ident,spanable}-pos-at-point` that just try the same unicode identifiers, and then some tests to distinguish `haskell-spanable-pos-at-point` by using an identifier in backticks. Any test for `haskell-ident-at-point` could also be a test for the other two, so that's a potential source of more tests; however, the definitions of the functions in terms of `haskell-ident-pos-at-point` are so simple that this didn't seem to add much (especially given the sheer amount of test duplication).
`haskell-mode-jump-to-tag` will now crash if given a non-`nil` non-string (inside `haskell-string-trim`), as gracjan requested in haskell#603.
Fix `haskell-ident-at-point` uses and `haskell-ident-pos-at-point` behavior
The documentation mandates that
haskell-ident-at-pointandhaskell-ident-pos-at-pointreturnnilif there is no identifier at point. However:haskell-ident-at-pointinstead returned""in that case.haskell-ident-pos-at-pointinstead returns a cons cell of the form(n . n)in that case.This pull request fixes two things:
haskell-ident-at-pointalways returned a string; these assumptions have all been fixed. (Commit f8521d9.)haskell-ident-pos-at-pointnow returnsnilcorrectly, and any code relying on the old behavior was fixed. (Commit 6a3257c.)(Fixing
haskell-ident-pos-at-pointindirectly fixeshaskell-spanable-pos-at-pointin the same way.)This directly fixes issue #334. It also indirectly solves the problem in pull requests #601 and #602:
haskell-contextual-spacewas comparinghaskell-ident-at-pointto""instead ofnilat one point.