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

Undo deleted lines mixes order #345

Closed
TelManuel opened this issue May 27, 2020 · 6 comments · Fixed by #362
Closed

Undo deleted lines mixes order #345

TelManuel opened this issue May 27, 2020 · 6 comments · Fixed by #362

Comments

@TelManuel
Copy link

I am pretty sure, that this one cannot be a general issue and it is related to my environment.

Starting point:

    1 line1
    2 line2
    3 line3
    4 line4

I delete line 3:

    1 line1
_1  2 line2
    3 line4

:SignifyHunkDiff on line 2 shows:

    1 -line3

If I now do :SignifyHunkUndo on line 2, I get:

_1  1 line1
    2 line3
+   3 line2
    4 line4

Deleted line is added above although it was deleted below. So the order is not correct anymore.

Not to deep into it, so I simply changed vim-signify/autoload/sy/repo.vim like this:

! 424       call append(new_line, text)

without being confident, this is it. In the end, it fixed the actual issue, but with this revoking changes on a line does not work any longer:

    1 line1
!   2 Line2
    3 line3
    4 line4

Hunk:

    1 -line2
    2 +Line2

Undo:

    1 line1
+   2 Line2
    3 line2
    4 line3
    5 line4

Error:

Error detected while processing function <SNR>59_callback_vim_close[9]..<SNR>59_handle_diff[31]..<SNR>59_undo_hunk:
line   24:
Could not apply addition hunk for undo. Try saving the buffer first.                                                              

Anyhow, probably it is a special issue on my environment and someone can help me to find out, what is wrong. In the other case, no one is apparently using the undo to get back deleted lines 🙂

@Arnie97
Copy link

Arnie97 commented Jun 21, 2020

I can reproduce this issue on nvim v0.3.4, nvim 0.4.3 and vim 8.1.2292.

@jumpnbrownweasel
Copy link

Happens for me also, in many cases.

@jumpnbrownweasel
Copy link

Does anyone know of a workaround?

@SanchayanMaity
Copy link

Have observed this every time for an one line change. Undo hunk just works incorrectly in that case as described.

@calid
Copy link

calid commented Oct 7, 2020

same for me

@noscript
Copy link

Same here.

@KapJI KapJI mentioned this issue Jan 22, 2021
KapJI added a commit to KapJI/vim-signify that referenced this issue Jan 22, 2021
Fixes mhinz#345

When `new_count` is `0` it's a special case meaning that lines should be inserted after `new_line`, not instead of it.

When you remove `line 2` from file:
```
line 1
line 2
line 3
line 4
```
the diff looks line this:
```diff
index 9c2a709..cbf7f40 100644
--- a/test.txt
+++ b/test.txt
@@ -2 +1,0 @@ line 1
-line 2
```

It means `line 2` in `undo` should be inserted below line 1 (`new_line`) and before it was inserted after line 0 (`new_line - 1`).
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 a pull request may close this issue.

6 participants