aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r--src/nvim/diff.c61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 3a7bd21c70..4e03f4761c 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -168,7 +168,7 @@ void diff_buf_add(buf_T *buf)
}
}
- EMSGN(_("E96: Cannot diff more than %" PRId64 " buffers"), DB_COUNT);
+ semsg(_("E96: Cannot diff more than %" PRId64 " buffers"), (int64_t)DB_COUNT);
}
///
@@ -391,7 +391,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T
off = 0;
if (last < line2) {
- // 2. delete at end of of diff
+ // 2. delete at end of diff
dp->df_count[idx] -= last - lnum_deleted + 1;
if ((dp->df_next != NULL)
@@ -638,7 +638,8 @@ static int diff_check_sanity(tabpage_T *tp, diff_T *dp)
void diff_redraw(bool dofold)
{
win_T *wp_other = NULL;
- bool used_max_fill = false;
+ bool used_max_fill_other = false;
+ bool used_max_fill_curwin = false;
need_diff_redraw = false;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
@@ -663,16 +664,24 @@ void diff_redraw(bool dofold)
} else if ((n > 0) && (n > wp->w_topfill)) {
wp->w_topfill = n;
if (wp == curwin) {
- used_max_fill = true;
+ used_max_fill_curwin = true;
+ } else if (wp_other != NULL) {
+ used_max_fill_other = true;
}
}
check_topfill(wp, false);
}
}
- if (wp_other != NULL && used_max_fill && curwin->w_p_scb) {
- // The current window was set to used the maximum number of filler
- // lines, may need to reduce them.
- diff_set_topline(wp_other, curwin);
+ if (wp_other != NULL && curwin->w_p_scb) {
+ if (used_max_fill_curwin) {
+ // The current window was set to used the maximum number of filler
+ // lines, may need to reduce them.
+ diff_set_topline(wp_other, curwin);
+ } else if (used_max_fill_other) {
+ // The other window was set to used the maximum number of filler
+ // lines, may need to reduce them.
+ diff_set_topline(curwin, wp_other);
+ }
}
}
@@ -735,7 +744,7 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din)
char_u cbuf[MB_MAXBYTES + 1];
// xdiff doesn't support ignoring case, fold-case the text.
- int c = PTR2CHAR(s);
+ int c = utf_ptr2char(s);
c = utf_fold(c);
const int orig_len = utfc_ptr2len(s);
if (utf_char2bytes(c, cbuf) != orig_len) {
@@ -1030,9 +1039,9 @@ static int check_external_diff(diffio_T *diffio)
if (!ok) {
if (io_error) {
- EMSG(_("E810: Cannot read or write temp files"));
+ emsg(_("E810: Cannot read or write temp files"));
}
- EMSG(_("E97: Cannot create diffs"));
+ emsg(_("E97: Cannot create diffs"));
diff_a_works = kNone;
return FAIL;
}
@@ -1073,7 +1082,7 @@ static int diff_file_internal(diffio_T *diffio)
if (xdl_diff(&diffio->dio_orig.din_mmfile,
&diffio->dio_new.din_mmfile,
&param, &emit_cfg, &emit_cb) < 0) {
- EMSG(_("E960: Problem creating the internal diff"));
+ emsg(_("E960: Problem creating the internal diff"));
return FAIL;
}
return OK;
@@ -1216,7 +1225,7 @@ void ex_diffpatch(exarg_T *eap)
#ifdef UNIX
if (dirbuf[0] != NUL) {
if (os_chdir((char *)dirbuf) != 0) {
- EMSG(_(e_prev_dir));
+ emsg(_(e_prev_dir));
}
shorten_fnames(true);
}
@@ -1235,7 +1244,7 @@ void ex_diffpatch(exarg_T *eap)
bool info_ok = os_fileinfo((char *)tmp_new, &file_info);
uint64_t filesize = os_fileinfo_size(&file_info);
if (!info_ok || filesize == 0) {
- EMSG(_("E816: Cannot read patch output"));
+ emsg(_("E816: Cannot read patch output"));
} else {
if (curbuf->b_fname != NULL) {
newname = vim_strnsave(curbuf->b_fname, STRLEN(curbuf->b_fname) + 4);
@@ -1527,7 +1536,7 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout)
enum {
DIFF_ED,
DIFF_UNIFIED,
- DIFF_NONE
+ DIFF_NONE,
} diffstyle = DIFF_NONE;
if (dout->dout_fname == NULL) {
@@ -1535,7 +1544,7 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout)
} else {
fd = os_fopen((char *)dout->dout_fname, "r");
if (fd == NULL) {
- EMSG(_("E98: Cannot read diff output"));
+ emsg(_("E98: Cannot read diff output"));
return;
}
}
@@ -1591,7 +1600,7 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout)
}
} else {
assert(diffstyle == DIFF_UNIFIED);
- if (STRNCMP(line, "@@ ", 3) != 0) {
+ if (STRNCMP(line, "@@ ", 3) != 0) {
continue; // not the start of a diff block
}
if (parse_diff_unified(line, &lnum_orig, &count_orig,
@@ -1699,7 +1708,7 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout)
notset = false; // "*dp" has been set
}
- // for remaining diff blocks orig and new are equal
+// for remaining diff blocks orig and new are equal
while (dp != NULL) {
if (notset) {
diff_copy_entry(dprev, dp, idx_orig, idx_new);
@@ -2488,7 +2497,7 @@ void ex_diffgetput(exarg_T *eap)
// Find the current buffer in the list of diff buffers.
int idx_cur = diff_buf_idx(curbuf);
if (idx_cur == DB_COUNT) {
- EMSG(_("E99: Current buffer is not in diff mode"));
+ emsg(_("E99: Current buffer is not in diff mode"));
return;
}
@@ -2507,9 +2516,9 @@ void ex_diffgetput(exarg_T *eap)
if (idx_other == DB_COUNT) {
if (found_not_ma) {
- EMSG(_("E793: No other buffer in diff mode is modifiable"));
+ emsg(_("E793: No other buffer in diff mode is modifiable"));
} else {
- EMSG(_("E100: No other buffer in diff mode"));
+ emsg(_("E100: No other buffer in diff mode"));
}
return;
}
@@ -2520,7 +2529,7 @@ void ex_diffgetput(exarg_T *eap)
&& (curtab->tp_diffbuf[i] != NULL)
&& ((eap->cmdidx != CMD_diffput)
|| MODIFIABLE(curtab->tp_diffbuf[i]))) {
- EMSG(_("E101: More than two buffers in diff mode, don't know "
+ emsg(_("E101: More than two buffers in diff mode, don't know "
"which one to use"));
return;
}
@@ -2549,7 +2558,7 @@ void ex_diffgetput(exarg_T *eap)
buf = buflist_findnr(i);
if (buf == NULL) {
- EMSG2(_("E102: Can't find buffer \"%s\""), eap->arg);
+ semsg(_("E102: Can't find buffer \"%s\""), eap->arg);
return;
}
@@ -2560,7 +2569,7 @@ void ex_diffgetput(exarg_T *eap)
idx_other = diff_buf_idx(buf);
if (idx_other == DB_COUNT) {
- EMSG2(_("E103: Buffer \"%s\" is not in diff mode"), eap->arg);
+ semsg(_("E103: Buffer \"%s\" is not in diff mode"), eap->arg);
return;
}
}
@@ -2601,7 +2610,7 @@ void ex_diffgetput(exarg_T *eap)
if (!curbuf->b_changed) {
change_warning(curbuf, 0);
if (diff_buf_idx(curbuf) != idx_to) {
- EMSG(_("E787: Buffer changed unexpectedly"));
+ emsg(_("E787: Buffer changed unexpectedly"));
goto theend;
}
}
@@ -3138,7 +3147,7 @@ static int xdiff_out(void *priv, mmbuffer_t *mb, int nbuf)
}
// sanity check
- if (STRNCMP(mb[0].ptr, "@@ ", 3) != 0) {
+ if (STRNCMP(mb[0].ptr, "@@ ", 3) != 0) {
return 0;
}