mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
shada: Always use merging when reading jumps and changes
This commit is contained in:
179
src/nvim/shada.c
179
src/nvim/shada.c
@@ -1360,67 +1360,53 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (force) {
|
const int jl_len = curwin->w_jumplistlen;
|
||||||
if (curwin->w_jumplistlen == JUMPLISTSIZE) {
|
int i;
|
||||||
// Jump list items are ignored in this case.
|
for (i = 0; i < jl_len; i++) {
|
||||||
free_xfmark(fm);
|
const xfmark_T jl_fm = curwin->w_jumplist[i];
|
||||||
} else {
|
if (jl_fm.fmark.timestamp >= cur_entry.timestamp) {
|
||||||
memmove(&curwin->w_jumplist[1], &curwin->w_jumplist[0],
|
if (marks_equal(fm.fmark.mark, jl_fm.fmark.mark)
|
||||||
sizeof(curwin->w_jumplist[0])
|
&& (buf == NULL
|
||||||
* (size_t) curwin->w_jumplistlen);
|
? (jl_fm.fname != NULL
|
||||||
curwin->w_jumplistidx++;
|
&& STRCMP(fm.fname, jl_fm.fname) == 0)
|
||||||
|
: fm.fmark.fnum == jl_fm.fmark.fnum)) {
|
||||||
|
i = -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i != -1) {
|
||||||
|
if (i < jl_len) {
|
||||||
|
if (jl_len == JUMPLISTSIZE) {
|
||||||
|
free_xfmark(curwin->w_jumplist[0]);
|
||||||
|
memmove(&curwin->w_jumplist[0], &curwin->w_jumplist[1],
|
||||||
|
sizeof(curwin->w_jumplist[0]) * (size_t) i);
|
||||||
|
} else {
|
||||||
|
memmove(&curwin->w_jumplist[i + 1], &curwin->w_jumplist[i],
|
||||||
|
sizeof(curwin->w_jumplist[0])
|
||||||
|
* (size_t) (jl_len - i));
|
||||||
|
}
|
||||||
|
} else if (i == jl_len) {
|
||||||
|
if (jl_len == JUMPLISTSIZE) {
|
||||||
|
i = -1;
|
||||||
|
} else if (jl_len > 0) {
|
||||||
|
memmove(&curwin->w_jumplist[1], &curwin->w_jumplist[0],
|
||||||
|
sizeof(curwin->w_jumplist[0])
|
||||||
|
* (size_t) jl_len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i != -1) {
|
||||||
|
curwin->w_jumplist[i] = fm;
|
||||||
|
if (jl_len < JUMPLISTSIZE) {
|
||||||
curwin->w_jumplistlen++;
|
curwin->w_jumplistlen++;
|
||||||
curwin->w_jumplist[0] = fm;
|
}
|
||||||
|
if (curwin->w_jumplistidx > i
|
||||||
|
&& curwin->w_jumplistidx + 1 < curwin->w_jumplistlen) {
|
||||||
|
curwin->w_jumplistidx++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const int jl_len = curwin->w_jumplistlen;
|
shada_free_shada_entry(&cur_entry);
|
||||||
int i;
|
|
||||||
for (i = 0; i < jl_len; i++) {
|
|
||||||
const xfmark_T jl_fm = curwin->w_jumplist[i];
|
|
||||||
if (jl_fm.fmark.timestamp >= cur_entry.timestamp) {
|
|
||||||
if (marks_equal(fm.fmark.mark, jl_fm.fmark.mark)
|
|
||||||
&& (buf == NULL
|
|
||||||
? (jl_fm.fname != NULL
|
|
||||||
&& STRCMP(fm.fname, jl_fm.fname) == 0)
|
|
||||||
: fm.fmark.fnum == jl_fm.fmark.fnum)) {
|
|
||||||
i = -1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i != -1) {
|
|
||||||
if (i < jl_len) {
|
|
||||||
if (jl_len == JUMPLISTSIZE) {
|
|
||||||
free_xfmark(curwin->w_jumplist[0]);
|
|
||||||
memmove(&curwin->w_jumplist[0], &curwin->w_jumplist[1],
|
|
||||||
sizeof(curwin->w_jumplist[0]) * (size_t) i);
|
|
||||||
} else {
|
|
||||||
memmove(&curwin->w_jumplist[i + 1], &curwin->w_jumplist[i],
|
|
||||||
sizeof(curwin->w_jumplist[0])
|
|
||||||
* (size_t) (jl_len - i));
|
|
||||||
}
|
|
||||||
} else if (i == jl_len) {
|
|
||||||
if (jl_len == JUMPLISTSIZE) {
|
|
||||||
i = -1;
|
|
||||||
} else if (jl_len > 0) {
|
|
||||||
memmove(&curwin->w_jumplist[1], &curwin->w_jumplist[0],
|
|
||||||
sizeof(curwin->w_jumplist[0])
|
|
||||||
* (size_t) jl_len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i != -1) {
|
|
||||||
curwin->w_jumplist[i] = fm;
|
|
||||||
if (jl_len < JUMPLISTSIZE) {
|
|
||||||
curwin->w_jumplistlen++;
|
|
||||||
}
|
|
||||||
if (curwin->w_jumplistidx > i
|
|
||||||
&& curwin->w_jumplistidx + 1 < curwin->w_jumplistlen) {
|
|
||||||
curwin->w_jumplistidx++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
shada_free_shada_entry(&cur_entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Do not free shada entry: its allocated memory was saved above.
|
// Do not free shada entry: its allocated memory was saved above.
|
||||||
@@ -1488,55 +1474,44 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
|||||||
} else {
|
} else {
|
||||||
int kh_ret;
|
int kh_ret;
|
||||||
(void) kh_put(bufset, &cl_bufs, (uintptr_t) buf, &kh_ret);
|
(void) kh_put(bufset, &cl_bufs, (uintptr_t) buf, &kh_ret);
|
||||||
if (force) {
|
const int cl_len = buf->b_changelistlen;
|
||||||
if (buf->b_changelistlen == JUMPLISTSIZE) {
|
int i;
|
||||||
|
for (i = cl_len; i > 0; i--) {
|
||||||
|
const fmark_T cl_fm = buf->b_changelist[i - 1];
|
||||||
|
if (cl_fm.timestamp <= cur_entry.timestamp) {
|
||||||
|
if (marks_equal(fm.mark, cl_fm.mark)) {
|
||||||
|
i = -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i > 0) {
|
||||||
|
if (cl_len == JUMPLISTSIZE) {
|
||||||
free_fmark(buf->b_changelist[0]);
|
free_fmark(buf->b_changelist[0]);
|
||||||
memmove(buf->b_changelist, buf->b_changelist + 1,
|
memmove(&buf->b_changelist[0], &buf->b_changelist[1],
|
||||||
sizeof(buf->b_changelist[0]) * (JUMPLISTSIZE - 1));
|
sizeof(buf->b_changelist[0]) * (size_t) i);
|
||||||
} else {
|
} else {
|
||||||
|
memmove(&buf->b_changelist[i + 1], &buf->b_changelist[i],
|
||||||
|
sizeof(buf->b_changelist[0])
|
||||||
|
* (size_t) (cl_len - i));
|
||||||
|
}
|
||||||
|
} else if (i == 0) {
|
||||||
|
if (cl_len == JUMPLISTSIZE) {
|
||||||
|
i = -1;
|
||||||
|
} else if (cl_len > 0) {
|
||||||
|
memmove(&buf->b_changelist[1], &buf->b_changelist[0],
|
||||||
|
sizeof(buf->b_changelist[0])
|
||||||
|
* (size_t) cl_len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i != -1) {
|
||||||
|
buf->b_changelist[i] = fm;
|
||||||
|
if (cl_len < JUMPLISTSIZE) {
|
||||||
buf->b_changelistlen++;
|
buf->b_changelistlen++;
|
||||||
}
|
}
|
||||||
buf->b_changelist[buf->b_changelistlen - 1] = fm;
|
|
||||||
} else {
|
} else {
|
||||||
const int cl_len = buf->b_changelistlen;
|
shada_free_shada_entry(&cur_entry);
|
||||||
int i;
|
cur_entry.data.filemark.fname = NULL;
|
||||||
for (i = cl_len; i > 0; i--) {
|
|
||||||
const fmark_T cl_fm = buf->b_changelist[i - 1];
|
|
||||||
if (cl_fm.timestamp <= cur_entry.timestamp) {
|
|
||||||
if (marks_equal(fm.mark, cl_fm.mark)) {
|
|
||||||
i = -1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i > 0) {
|
|
||||||
if (cl_len == JUMPLISTSIZE) {
|
|
||||||
free_fmark(buf->b_changelist[0]);
|
|
||||||
memmove(&buf->b_changelist[0], &buf->b_changelist[1],
|
|
||||||
sizeof(buf->b_changelist[0]) * (size_t) i);
|
|
||||||
} else {
|
|
||||||
memmove(&buf->b_changelist[i + 1], &buf->b_changelist[i],
|
|
||||||
sizeof(buf->b_changelist[0])
|
|
||||||
* (size_t) (cl_len - i));
|
|
||||||
}
|
|
||||||
} else if (i == 0) {
|
|
||||||
if (cl_len == JUMPLISTSIZE) {
|
|
||||||
i = -1;
|
|
||||||
} else if (cl_len > 0) {
|
|
||||||
memmove(&buf->b_changelist[1], &buf->b_changelist[0],
|
|
||||||
sizeof(buf->b_changelist[0])
|
|
||||||
* (size_t) cl_len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i != -1) {
|
|
||||||
buf->b_changelist[i] = fm;
|
|
||||||
if (cl_len < JUMPLISTSIZE) {
|
|
||||||
buf->b_changelistlen++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
shada_free_shada_entry(&cur_entry);
|
|
||||||
cur_entry.data.filemark.fname = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Do not free shada entry: except for fname, its allocated memory (i.e.
|
// Do not free shada entry: except for fname, its allocated memory (i.e.
|
||||||
|
Reference in New Issue
Block a user