Skip to content

Conversation

@mcelrath
Copy link

This is a stab at fixing #36. It fixes the formatting after rejecting an edit for the one example I was testing on, but there is a lot of other problems with this code, so don't merge this yet.

An error was getting thrown:

Error in DialogCallback: line number out of range at line 5 of <string>Error in delegating callback: line number out of range

because lineno was not being tracked correctly, and a bunch of vim signs were getting added to the same line after removal. So instead I call VimHelper.DeleteLine(start_line) -- if it's a block of pure adds, they appear to all be on the same line.

The code for "changed" lines is pretty borked though. That should only get applied if it's a one-line change, and be shown as adds and deletes if not.

Comment on lines +657 to +658
start_line = group.get('start_line', 1) - g_restored_lines
end_line = group.get('end_line', 1) - g_restored_lines
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think this is correct. Restored lines are "deleted lines" that were restored by rejecting this change.
We need to add this new lines to compensate the changed line numbers after this change, so that the next change is proceeded at the correct start_line.
When lines are added (restored) the start_line of the next change must increase.

VimHelper.DeleteLine(lineno)
VimHelper.DeleteLine(start_line)
g_restored_lines += 1
lineno += 1
Copy link
Owner

Choose a reason for hiding this comment

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

The current lineno does not change when deleting a line (undoing the add).
Maybe we need a g_restored_lines -= 1 here? Incrementing makes no sense.

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