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

ivy-read and text properties #1724

Closed
jdz opened this issue Aug 21, 2018 · 1 comment
Closed

ivy-read and text properties #1724

jdz opened this issue Aug 21, 2018 · 1 comment

Comments

@jdz
Copy link

@jdz jdz commented Aug 21, 2018

Currently there are cases where ivy-read returns a propertized string (see test case below). There is code at the end of ivy-read that removes idx property, but it is done after the function return value has been calculated (prog1).

I think this is a bug with Ivy because:

  • ivy-completing-read is supposed to be compatible with completing-read, and it is not if there are observable differences between the two given the same inputs.
  • The idx property is an implementation detail of Ivy that should not be leaking out.

At the moment I'm using an advice around ivy-read to strip away any text properties (using substring-no-properties), but it would be nice if the library could be fixed properly.

(ert-deftest ivy-read-no-properties ()
  (should (equal
           (format "%S" (ivy-with '(ivy-read "pattern: " '(("whatever")))
                                  "RET"))
           "whatever")))
basil-conto added a commit to basil-conto/swiper that referenced this issue Aug 21, 2018
Strip idx property from entire candidate returned

ivy.el (ivy-read): Strip idx property from entire candidate returned
following commit 4ca8786
"ivy.el: Avoid modifying alist collection".
ivy-test.el (ivy-read): Test idx property removal.

Re: abo-abo#1706
Fixes abo-abo#1724
@basil-conto
Copy link
Collaborator

@basil-conto basil-conto commented Aug 21, 2018

There is code at the end of ivy-read that removes idx property, but it is done after the function return value has been calculated (prog1).

The property is also removed from the return value of prog1 - they are the same string object.

I think this is a bug with Ivy

Yes, this is a regression caused by 4ca8786 which applies the idx property to the entire string, whereas ivy-read removes it only from the first character of non-empty strings.

I've submitted PR #1725 which should fix this; please test. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants