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

wgrep fails with swiper + ivy-occur in a narrowed buffer #1848

Closed
whatacold opened this issue Dec 8, 2018 · 2 comments
Closed

wgrep fails with swiper + ivy-occur in a narrowed buffer #1848

whatacold opened this issue Dec 8, 2018 · 2 comments

Comments

@whatacold
Copy link
Contributor

@whatacold whatacold commented Dec 8, 2018

Hi,

There are times that I edit texts in a narrowed buffer,
and I found that wgrep fails to work with the result of swiper occur.

For example, I have a test-swiper-occur-wgrep-in-narrowed-buffer.txt with a few lines:

foo
bar
baz
foobar

I narrow the buffer to the last two lines:

baz
foobar

And do an occur with ivy-occur:

-*- mode:grep; default-directory: "/home/hgw/test/" -*-


2 candidates:
./test-swiper-occur-wgrep-in-narrowed-buffer.txt:1:baz
./test-swiper-occur-wgrep-in-narrowed-buffer.txt:2:foobar

Activate wgrep in the buffer, editing some text and commit the changes with wgrep-finish-edit,
then wgrep complains:

There is an unapplied change. (0 changed)

I suspect it's because the line number parts of the occur buffer are wrong when being narrowed.

I've verified that it exists with the latest version from melpa with a clean emacs -Q instance,
the versions are:

  swiper             20181120.1832
  wgrep              2.1.10
  ivy                20181129.2105
@CeleritasCelery
Copy link
Contributor

@CeleritasCelery CeleritasCelery commented Mar 27, 2019

I suspect it's because the line number parts of the occur buffer are wrong when being narrowed.

that is correct. However I don't see an easy way to fix this because if we just get the real numbers it will prevent us from using "RET" to jump to that line, at least not without a lot of translation.

If this is a big part of your workflow you can check out helm-swoop which handles this correctly.

@abo-abo abo-abo closed this in 4c52362 Mar 28, 2019
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Mar 28, 2019

Thanks, please test.

astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
* swiper.el (swiper--occur-cands): Extract and add `line-delta' logic.
(swiper-occur): Update.
(swiper--action): Use `swiper--point-min' only when the buffer is narrowed.

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

Successfully merging a pull request may close this issue.

None yet
3 participants