mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 05:48:17 +00:00
@@ -282,6 +282,27 @@ bool buf_valid(buf_T *buf)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map used to quickly lookup a buffer by its number.
|
||||||
|
static PMap(handle_T) *buf_map = NULL;
|
||||||
|
|
||||||
|
static void buf_hashtab_add(buf_T *buf)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
if (pmap_has(handle_T)(buf_map, buf->handle)) {
|
||||||
|
EMSG(_("E931: Buffer cannot be registered"));
|
||||||
|
} else {
|
||||||
|
pmap_put(handle_T)(buf_map, buf->handle, buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void buf_hashtab_remove(buf_T *buf)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
if (pmap_has(handle_T)(buf_map, buf->handle)) {
|
||||||
|
pmap_del(handle_T)(buf_map, buf->handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Close the link to a buffer.
|
/// Close the link to a buffer.
|
||||||
///
|
///
|
||||||
/// @param win If not NULL, set b_last_cursor.
|
/// @param win If not NULL, set b_last_cursor.
|
||||||
@@ -585,6 +606,7 @@ static void free_buffer(buf_T *buf)
|
|||||||
free_buffer_stuff(buf, TRUE);
|
free_buffer_stuff(buf, TRUE);
|
||||||
unref_var_dict(buf->b_vars);
|
unref_var_dict(buf->b_vars);
|
||||||
aubuflocal_remove(buf);
|
aubuflocal_remove(buf);
|
||||||
|
buf_hashtab_remove(buf);
|
||||||
dict_unref(buf->additional_data);
|
dict_unref(buf->additional_data);
|
||||||
clear_fmark(&buf->b_last_cursor);
|
clear_fmark(&buf->b_last_cursor);
|
||||||
clear_fmark(&buf->b_last_insert);
|
clear_fmark(&buf->b_last_insert);
|
||||||
@@ -1369,7 +1391,10 @@ buf_T * buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags)
|
|||||||
{
|
{
|
||||||
buf_T *buf;
|
buf_T *buf;
|
||||||
|
|
||||||
fname_expand(curbuf, &ffname, &sfname); /* will allocate ffname */
|
if (top_file_num == 1) {
|
||||||
|
buf_map = pmap_new(handle_T)();
|
||||||
|
}
|
||||||
|
fname_expand(curbuf, &ffname, &sfname); // will allocate ffname
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If file name already exists in the list, update the entry.
|
* If file name already exists in the list, update the entry.
|
||||||
@@ -1493,6 +1518,7 @@ buf_T * buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags)
|
|||||||
}
|
}
|
||||||
top_file_num = 1;
|
top_file_num = 1;
|
||||||
}
|
}
|
||||||
|
buf_hashtab_add(buf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Always copy the options from the current buffer.
|
* Always copy the options from the current buffer.
|
||||||
@@ -2002,19 +2028,15 @@ static char_u *fname_match(regmatch_T *rmp, char_u *name, bool ignore_case)
|
|||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Find a file in the buffer list by buffer number.
|
||||||
* find file in buffer list by number
|
|
||||||
*/
|
|
||||||
buf_T *buflist_findnr(int nr)
|
buf_T *buflist_findnr(int nr)
|
||||||
{
|
{
|
||||||
if (nr == 0) {
|
if (nr == 0) {
|
||||||
nr = curwin->w_alt_fnum;
|
nr = curwin->w_alt_fnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_ALL_BUFFERS(buf) {
|
if (pmap_has(handle_T)(buf_map, (handle_T)nr)) {
|
||||||
if (buf->b_fnum == nr) {
|
return pmap_get(handle_T)(buf_map, (handle_T)nr);
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -404,7 +404,7 @@ static int included_patches[] = {
|
|||||||
// 2039 NA
|
// 2039 NA
|
||||||
// 2038 NA
|
// 2038 NA
|
||||||
// 2037 NA
|
// 2037 NA
|
||||||
// 2036,
|
2036,
|
||||||
// 2035 NA
|
// 2035 NA
|
||||||
// 2034 NA
|
// 2034 NA
|
||||||
2033,
|
2033,
|
||||||
|
Reference in New Issue
Block a user