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

fix(vim.diff): correctly apply hunk offsets with linematch #20931

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(vim.diff): correctly apply hunk offsets with linematch
  • Loading branch information
lewis6991 committed Nov 4, 2022
commit 5bebeeae05bfaa6c138f4b72bd0bbc65c4fdf9dc
18 changes: 9 additions & 9 deletions src/nvim/lua/xdiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ typedef struct {

static void lua_pushhunk(lua_State *lstate, long start_a, long count_a, long start_b, long count_b)
{
// Mimic extra offsets done by xdiff, see:
// src/xdiff/xemit.c:284
// src/xdiff/xutils.c:(356,368)
if (count_a > 0) {
start_a += 1;
}
if (count_b > 0) {
start_b += 1;
}
lua_createtable(lstate, 0, 0);
lua_pushinteger(lstate, start_a);
lua_rawseti(lstate, -2, 1);
Expand Down Expand Up @@ -116,15 +125,6 @@ static int write_string(void *priv, mmbuffer_t *mb, int nbuf)
// hunk_func callback used when opts.hunk_lines = true
static int hunk_locations_cb(long start_a, long count_a, long start_b, long count_b, void *cb_data)
{
// Mimic extra offsets done by xdiff, see:
// src/xdiff/xemit.c:284
// src/xdiff/xutils.c:(356,368)
if (count_a > 0) {
start_a += 1;
}
if (count_b > 0) {
start_b += 1;
}
hunkpriv_t *priv = (hunkpriv_t *)cb_data;
lua_State *lstate = priv->lstate;
if (priv->linematch) {
Expand Down