aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2022-11-04 11:12:17 +0000
committerGitHub <noreply@github.com>2022-11-04 11:12:17 +0000
commitb854f2ce093de9593278b371de796f2ace044376 (patch)
tree8f717cc11e5ea13a75a0286e580973b28b98c5bb
parentf1c864cfe340dbb225caaf3dcbe28ee705be9f75 (diff)
downloadrneovim-b854f2ce093de9593278b371de796f2ace044376.tar.gz
rneovim-b854f2ce093de9593278b371de796f2ace044376.tar.bz2
rneovim-b854f2ce093de9593278b371de796f2ace044376.zip
fix(vim.diff): correctly apply hunk offsets with linematch (#20931)
-rw-r--r--src/nvim/lua/xdiff.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c
index ec7dc3c666..3adb6088fc 100644
--- a/src/nvim/lua/xdiff.c
+++ b/src/nvim/lua/xdiff.c
@@ -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);
@@ -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) {