mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
vim-patch:partial:8.1.1981: the evalfunc.c file is too big (#24490)
Problem: The evalfunc.c file is too big.
Solution: Move undo functions to undo.c. Move cmdline functions to
ex_getln.c. Move some container functions to list.c.
08c308aeb5
Undo functions only. Cmdline functions have already been moved.
A lot of container functions have been added to eval/funcs.c instead of
list.c in previously ported Vim 8.2.x patches, so deal with that later.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
14d047ad2f
commit
b8b7782037
@ -114,7 +114,6 @@
|
|||||||
#include "nvim/syntax.h"
|
#include "nvim/syntax.h"
|
||||||
#include "nvim/tag.h"
|
#include "nvim/tag.h"
|
||||||
#include "nvim/ui.h"
|
#include "nvim/ui.h"
|
||||||
#include "nvim/undo.h"
|
|
||||||
#include "nvim/version.h"
|
#include "nvim/version.h"
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
#include "nvim/window.h"
|
#include "nvim/window.h"
|
||||||
@ -8629,43 +8628,6 @@ static void f_type(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
rettv->vval.v_number = n;
|
rettv->vval.v_number = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "undofile(name)" function
|
|
||||||
static void f_undofile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|
||||||
{
|
|
||||||
rettv->v_type = VAR_STRING;
|
|
||||||
const char *const fname = tv_get_string(&argvars[0]);
|
|
||||||
|
|
||||||
if (*fname == NUL) {
|
|
||||||
// If there is no file name there will be no undo file.
|
|
||||||
rettv->vval.v_string = NULL;
|
|
||||||
} else {
|
|
||||||
char *ffname = FullName_save(fname, true);
|
|
||||||
|
|
||||||
if (ffname != NULL) {
|
|
||||||
rettv->vval.v_string = u_get_undo_file_name(ffname, false);
|
|
||||||
}
|
|
||||||
xfree(ffname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// "undotree()" function
|
|
||||||
static void f_undotree(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|
||||||
{
|
|
||||||
tv_dict_alloc_ret(rettv);
|
|
||||||
|
|
||||||
dict_T *dict = rettv->vval.v_dict;
|
|
||||||
|
|
||||||
tv_dict_add_nr(dict, S_LEN("synced"), (varnumber_T)curbuf->b_u_synced);
|
|
||||||
tv_dict_add_nr(dict, S_LEN("seq_last"), (varnumber_T)curbuf->b_u_seq_last);
|
|
||||||
tv_dict_add_nr(dict, S_LEN("save_last"),
|
|
||||||
(varnumber_T)curbuf->b_u_save_nr_last);
|
|
||||||
tv_dict_add_nr(dict, S_LEN("seq_cur"), (varnumber_T)curbuf->b_u_seq_cur);
|
|
||||||
tv_dict_add_nr(dict, S_LEN("time_cur"), (varnumber_T)curbuf->b_u_time_cur);
|
|
||||||
tv_dict_add_nr(dict, S_LEN("save_cur"), (varnumber_T)curbuf->b_u_save_nr_cur);
|
|
||||||
|
|
||||||
tv_dict_add_list(dict, S_LEN("entries"), u_eval_tree(curbuf->b_u_oldhead));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// "virtcol(string, bool)" function
|
/// "virtcol(string, bool)" function
|
||||||
static void f_virtcol(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
static void f_virtcol(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,7 @@ hashpipe:write([[
|
|||||||
#include "nvim/strings.h"
|
#include "nvim/strings.h"
|
||||||
#include "nvim/sign.h"
|
#include "nvim/sign.h"
|
||||||
#include "nvim/testing.h"
|
#include "nvim/testing.h"
|
||||||
|
#include "nvim/undo.h"
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
@ -3118,7 +3118,7 @@ bool curbufIsChanged(void)
|
|||||||
/// @param[in] first_uhp Undo blocks list to start with.
|
/// @param[in] first_uhp Undo blocks list to start with.
|
||||||
///
|
///
|
||||||
/// @return [allocated] List with a representation of undo blocks.
|
/// @return [allocated] List with a representation of undo blocks.
|
||||||
list_T *u_eval_tree(const u_header_T *const first_uhp)
|
static list_T *u_eval_tree(const u_header_T *const first_uhp)
|
||||||
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET
|
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET
|
||||||
{
|
{
|
||||||
list_T *const list = tv_list_alloc(kListLenMayKnow);
|
list_T *const list = tv_list_alloc(kListLenMayKnow);
|
||||||
@ -3148,6 +3148,42 @@ list_T *u_eval_tree(const u_header_T *const first_uhp)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// "undofile(name)" function
|
||||||
|
void f_undofile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||||
|
{
|
||||||
|
rettv->v_type = VAR_STRING;
|
||||||
|
const char *const fname = tv_get_string(&argvars[0]);
|
||||||
|
|
||||||
|
if (*fname == NUL) {
|
||||||
|
// If there is no file name there will be no undo file.
|
||||||
|
rettv->vval.v_string = NULL;
|
||||||
|
} else {
|
||||||
|
char *ffname = FullName_save(fname, true);
|
||||||
|
|
||||||
|
if (ffname != NULL) {
|
||||||
|
rettv->vval.v_string = u_get_undo_file_name(ffname, false);
|
||||||
|
}
|
||||||
|
xfree(ffname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// "undotree()" function
|
||||||
|
void f_undotree(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||||
|
{
|
||||||
|
tv_dict_alloc_ret(rettv);
|
||||||
|
|
||||||
|
dict_T *dict = rettv->vval.v_dict;
|
||||||
|
|
||||||
|
tv_dict_add_nr(dict, S_LEN("synced"), (varnumber_T)curbuf->b_u_synced);
|
||||||
|
tv_dict_add_nr(dict, S_LEN("seq_last"), (varnumber_T)curbuf->b_u_seq_last);
|
||||||
|
tv_dict_add_nr(dict, S_LEN("save_last"), (varnumber_T)curbuf->b_u_save_nr_last);
|
||||||
|
tv_dict_add_nr(dict, S_LEN("seq_cur"), (varnumber_T)curbuf->b_u_seq_cur);
|
||||||
|
tv_dict_add_nr(dict, S_LEN("time_cur"), (varnumber_T)curbuf->b_u_time_cur);
|
||||||
|
tv_dict_add_nr(dict, S_LEN("save_cur"), (varnumber_T)curbuf->b_u_save_nr_cur);
|
||||||
|
|
||||||
|
tv_dict_add_list(dict, S_LEN("entries"), u_eval_tree(curbuf->b_u_oldhead));
|
||||||
|
}
|
||||||
|
|
||||||
// Given the buffer, Return the undo header. If none is set, set one first.
|
// Given the buffer, Return the undo header. If none is set, set one first.
|
||||||
// NULL will be returned if e.g undolevels = -1 (undo disabled)
|
// NULL will be returned if e.g undolevels = -1 (undo disabled)
|
||||||
u_header_T *u_force_get_undo_header(buf_T *buf)
|
u_header_T *u_force_get_undo_header(buf_T *buf)
|
||||||
|
Loading…
Reference in New Issue
Block a user