From 8410c72b18b0c2d8cfbf98e57e2ab8869dd6af01 Mon Sep 17 00:00:00 2001 From: Said Al Attrach Date: Sun, 10 Mar 2019 18:08:45 +0100 Subject: [PATCH 01/10] fs: add os_copy function that uses uv_fs_copyfile --- src/nvim/fileio.c | 24 +++--------------------- src/nvim/os/fs.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index f111376d84..2828e7bddc 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -3517,28 +3517,10 @@ restore_backup: MSG(_(e_interr)); ui_flush(); } - if ((fd = os_open((char *)backup, O_RDONLY, 0)) >= 0) { - if ((write_info.bw_fd = os_open((char *)fname, - O_WRONLY | O_CREAT | O_TRUNC, - perm & 0777)) >= 0) { - // copy the file. - write_info.bw_buf = smallbuf; -#ifdef HAS_BW_FLAGS - write_info.bw_flags = FIO_NOCONVERT; -#endif - while ((write_info.bw_len = read_eintr(fd, smallbuf, - SMBUFSIZE)) > 0) { - if (buf_write_bytes(&write_info) == FAIL) { - break; - } - } - if (close(write_info.bw_fd) >= 0 - && write_info.bw_len == 0) { - end = 1; // success - } - } - close(fd); // ignore errors for closing read file + // copy the file. + if (os_copy((char *)backup, (char *)fname, 0) == 0) { + end = 1; } } else { if (vim_rename(backup, fname) == 0) { diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 27db675c52..81d3b0a2e9 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -643,6 +643,20 @@ ptrdiff_t os_write(const int fd, const char *const buf, const size_t size, return (ptrdiff_t)written_bytes; } +/// Copies a file from path to new_path. Currently this passes +/// the arguments through to uv_fs_copyfile. +/// +/// @param path Path of file to be copied +/// @param path_new Path of new file +/// @param flags Bitwise OR of flags defined in +/// @return libuv error code on error +int os_copy(const char *path, const char *new_path, int flags) +{ + int r; + RUN_UV_FS_FUNC(r, uv_fs_copyfile, path, new_path, flags, NULL); + return r; +} + /// Flushes file modifications to disk. /// /// @param fd the file descriptor of the file to flush to disk. From 7a6d85a778625ba83954a9e73e53e22ea9d53b4d Mon Sep 17 00:00:00 2001 From: Said Al Attrach Date: Sun, 10 Mar 2019 19:48:56 +0100 Subject: [PATCH 02/10] fs: replace another custom copy with os_copy --- src/nvim/fileio.c | 80 +++++++---------------------------------------- 1 file changed, 11 insertions(+), 69 deletions(-) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 2828e7bddc..1e89baa8ce 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2762,7 +2762,6 @@ buf_write ( backup_ext = p_bex; if (backup_copy && (fd = os_open((char *)fname, O_RDONLY, 0)) >= 0) { - int bfd; char_u *copybuf, *wp; int some_error = FALSE; char_u *dirp; @@ -2855,81 +2854,24 @@ buf_write ( if (backup != NULL) { /* remove old backup, if present */ os_remove((char *)backup); - /* Open with O_EXCL to avoid the file being created while - * we were sleeping (symlink hacker attack?) */ - bfd = os_open((char *)backup, - O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW, - perm & 0777); - if (bfd < 0) { - xfree(backup); - backup = NULL; - } else { - // set file protection same as original file, but - // strip s-bit. - (void)os_setperm((const char *)backup, perm & 0777); + + /* copy the file */ + if (os_copy((char *)fname, (char *)backup, 0) != 0) { + SET_ERRMSG(_("E506: Can't write to backup file (add ! to override)")); + } #ifdef UNIX - /* - * Try to set the group of the backup same as the - * original file. If this fails, set the protection - * bits for the group same as the protection bits for - * others. - */ - if (file_info_new.stat.st_gid != file_info_old.stat.st_gid - && os_fchown(bfd, -1, file_info_old.stat.st_gid) != 0) { - os_setperm((const char *)backup, - (perm & 0707) | ((perm & 07) << 3)); - } -# ifdef HAVE_SELINUX - mch_copy_sec(fname, backup); -# endif -#endif - - /* - * copy the file. - */ - write_info.bw_fd = bfd; - write_info.bw_buf = copybuf; -#ifdef HAS_BW_FLAGS - write_info.bw_flags = FIO_NOCONVERT; -#endif - while ((write_info.bw_len = read_eintr(fd, copybuf, - BUFSIZE)) > 0) { - if (buf_write_bytes(&write_info) == FAIL) { - SET_ERRMSG(_( - "E506: Can't write to backup file (add ! to override)")); - break; - } - os_breakcheck(); - if (got_int) { - SET_ERRMSG(_(e_interr)); - break; - } - } - - int error; - if ((error = os_close(bfd)) != 0 && errmsg == NULL) { - SET_ERRMSG_ARG(_("E507: Close error for backup file " - "(add ! to override): %s"), - error); - } - if (write_info.bw_len < 0) { - SET_ERRMSG(_( - "E508: Can't read file for backup (add ! to override)")); - } -#ifdef UNIX - set_file_time(backup, - file_info_old.stat.st_atim.tv_sec, - file_info_old.stat.st_mtim.tv_sec); + set_file_time(backup, + file_info_old.stat.st_atim.tv_sec, + file_info_old.stat.st_mtim.tv_sec); #endif #ifdef HAVE_ACL - mch_set_acl(backup, acl); + mch_set_acl(backup, acl); #endif #ifdef HAVE_SELINUX - mch_copy_sec(fname, backup); + mch_copy_sec(fname, backup); #endif - break; - } + break; } } nobackup: From 6db1757b53d562c0bdae43028aca5ec955c39acc Mon Sep 17 00:00:00 2001 From: Said Al Attrach Date: Sun, 10 Mar 2019 20:50:56 +0100 Subject: [PATCH 03/10] fs: remove unecessary copybuf and os_open call --- src/nvim/fileio.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 1e89baa8ce..7a77e7df24 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2761,19 +2761,12 @@ buf_write ( else backup_ext = p_bex; - if (backup_copy && (fd = os_open((char *)fname, O_RDONLY, 0)) >= 0) { - char_u *copybuf, *wp; + if (backup_copy) { + char_u *wp; int some_error = FALSE; char_u *dirp; char_u *rootname; - copybuf = verbose_try_malloc(BUFSIZE + 1); - if (copybuf == NULL) { - // out of memory - some_error = TRUE; - goto nobackup; - } - /* * Try to make the backup in each directory in the 'bdir' option. * @@ -2791,8 +2784,8 @@ buf_write ( /* * Isolate one directory name, using an entry in 'bdir'. */ - (void)copy_option_part(&dirp, copybuf, BUFSIZE, ","); - rootname = get_file_in_dir(fname, copybuf); + (void)copy_option_part(&dirp, IObuff, IOSIZE, ","); + rootname = get_file_in_dir(fname, IObuff); if (rootname == NULL) { some_error = TRUE; /* out of memory */ goto nobackup; @@ -2874,10 +2867,8 @@ buf_write ( break; } } -nobackup: - os_close(fd); // Ignore errors for closing read file. - xfree(copybuf); +nobackup: if (backup == NULL && errmsg == NULL) { SET_ERRMSG(_( "E509: Cannot create backup file (add ! to override)")); From b4d894c06709b4ae807d540dfda21ab3220a989a Mon Sep 17 00:00:00 2001 From: Said Al Attrach Date: Mon, 11 Mar 2019 11:55:58 +0100 Subject: [PATCH 04/10] fs: add UV_FS_COPYFILE_FICLONE flag to os_copy --- src/nvim/fileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 7a77e7df24..5ef576e9bb 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2849,7 +2849,7 @@ buf_write ( os_remove((char *)backup); /* copy the file */ - if (os_copy((char *)fname, (char *)backup, 0) != 0) { + if (os_copy((char *)fname, (char *)backup, UV_FS_COPYFILE_FICLONE) != 0) { SET_ERRMSG(_("E506: Can't write to backup file (add ! to override)")); } @@ -3452,7 +3452,7 @@ restore_backup: } // copy the file. - if (os_copy((char *)backup, (char *)fname, 0) == 0) { + if (os_copy((char *)backup, (char *)fname, UV_FS_COPYFILE_FICLONE) == 0) { end = 1; } } else { From f4c2de4c458f3f80771f717b3de0b50bd548e906 Mon Sep 17 00:00:00 2001 From: Said Al Attrach Date: Mon, 11 Mar 2019 12:31:14 +0100 Subject: [PATCH 05/10] style: make linter happy with fileio.c --- src/nvim/fileio.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 5ef576e9bb..08a4b76783 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2763,7 +2763,7 @@ buf_write ( if (backup_copy) { char_u *wp; - int some_error = FALSE; + int some_error = false; char_u *dirp; char_u *rootname; @@ -2848,9 +2848,11 @@ buf_write ( /* remove old backup, if present */ os_remove((char *)backup); - /* copy the file */ - if (os_copy((char *)fname, (char *)backup, UV_FS_COPYFILE_FICLONE) != 0) { - SET_ERRMSG(_("E506: Can't write to backup file (add ! to override)")); + // copy the file + if (os_copy((char *)fname, (char *)backup, UV_FS_COPYFILE_FICLONE) + != 0) { + SET_ERRMSG(_("E506: Can't write to backup file " + "(add ! to override)")); } #ifdef UNIX @@ -3452,7 +3454,8 @@ restore_backup: } // copy the file. - if (os_copy((char *)backup, (char *)fname, UV_FS_COPYFILE_FICLONE) == 0) { + if (os_copy((char *)backup, (char *)fname, UV_FS_COPYFILE_FICLONE) + == 0) { end = 1; } } else { From a9df3fa5d2ee41b165b1e740fe27eddbf9dbf4a5 Mon Sep 17 00:00:00 2001 From: Said Al Attrach Date: Sun, 24 Mar 2019 00:21:26 +0100 Subject: [PATCH 06/10] test: make first attempt at some kind of test --- test/functional/core/fileio_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua index 09533e4e60..94d9536bfc 100644 --- a/test/functional/core/fileio_spec.lua +++ b/test/functional/core/fileio_spec.lua @@ -10,6 +10,7 @@ local request = helpers.request local retry = helpers.retry local rmdir = helpers.rmdir local sleep = helpers.sleep +local read_file = helpers.read_file describe('fileio', function() before_each(function() @@ -18,6 +19,7 @@ describe('fileio', function() command(':qall!') os.remove('Xtest_startup_shada') os.remove('Xtest_startup_file1') + os.remove('Xtest_startup_file1~') os.remove('Xtest_startup_file2') rmdir('Xtest_startup_swapdir') end) @@ -64,5 +66,25 @@ describe('fileio', function() command('write') eq(4, request('nvim__stats').fsync) end) + + it('creates a backup', function() + clear({ args={ '-i', 'Xtest_startup_shada', + '--cmd', 'set directory=Xtest_startup_swapdir' } }) + + command('write Xtest_startup_file1') + feed('ifoo') + command('set backup') + command('set backupcopy=yes') + command('write') + feed('Abar') + command('write') + + local foo_contents = read_file('Xtest_startup_file1') + local bar_contents = read_file('Xtest_startup_file1~') + + eq('foobar\n', foo_contents); + eq('foo\n', bar_contents); + + end) end) From 2bf18e7843542dd4ba3bfaa3b09078401bfb6b7b Mon Sep 17 00:00:00 2001 From: Said Al Attrach Date: Sat, 30 Mar 2019 18:14:20 +0100 Subject: [PATCH 07/10] test: move trim to global helpers --- test/functional/core/fileio_spec.lua | 9 +++++---- test/functional/helpers.lua | 2 ++ test/helpers.lua | 5 +++++ test/unit/helpers.lua | 5 +---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua index 94d9536bfc..6468aa9d0a 100644 --- a/test/functional/core/fileio_spec.lua +++ b/test/functional/core/fileio_spec.lua @@ -11,6 +11,7 @@ local retry = helpers.retry local rmdir = helpers.rmdir local sleep = helpers.sleep local read_file = helpers.read_file +local trim = helpers.trim describe('fileio', function() before_each(function() @@ -79,11 +80,11 @@ describe('fileio', function() feed('Abar') command('write') - local foo_contents = read_file('Xtest_startup_file1') - local bar_contents = read_file('Xtest_startup_file1~') + local foobar_contents = trim(read_file('Xtest_startup_file1')) + local bar_contents = trim(read_file('Xtest_startup_file1~')) - eq('foobar\n', foo_contents); - eq('foo\n', bar_contents); + eq('foobar', foobar_contents); + eq('foo', bar_contents); end) end) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 3e72ba6f98..9d82ce9c0d 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -25,6 +25,7 @@ local read_file = global_helpers.read_file local sleep = global_helpers.sleep local table_flatten = global_helpers.table_flatten local write_file = global_helpers.write_file +local trim = global_helpers.trim local start_dir = lfs.currentdir() -- XXX: NVIM_PROG takes precedence, QuickBuild sets it. @@ -797,6 +798,7 @@ local module = { window = window, winmeths = winmeths, write_file = write_file, + trim = trim, } return function(after_each) diff --git a/test/helpers.lua b/test/helpers.lua index e4c3019adc..3a766b99f5 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -731,6 +731,10 @@ local function read_nvim_log() return log end +local function trim(s) + return s:match('^%s*(.*%S)') or '' +end + local module = { REMOVE_THIS = REMOVE_THIS, argss_to_cmd = argss_to_cmd, @@ -772,6 +776,7 @@ local module = { updated = updated, which = which, write_file = write_file, + trim = trim, } return module diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua index beb25f25db..1345fbce17 100644 --- a/test/unit/helpers.lua +++ b/test/unit/helpers.lua @@ -16,6 +16,7 @@ local neq = global_helpers.neq local map = global_helpers.map local eq = global_helpers.eq local ok = global_helpers.ok +local trim = global_helpers.trim -- C constants. local NULL = ffi.cast('void*', 0) @@ -120,10 +121,6 @@ local deinit = only_separate(function() end end) -local function trim(s) - return s:match('^%s*(.*%S)') or '' -end - -- a Set that keeps around the lines we've already seen local cdefs_init = Set:new() local cdefs_mod = nil From 6feb9cb09d243eb811e301b39dbfbba5863617be Mon Sep 17 00:00:00 2001 From: Said Al Attrach Date: Sat, 30 Mar 2019 18:15:08 +0100 Subject: [PATCH 08/10] docs: explicitly state return value on success --- src/nvim/os/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 81d3b0a2e9..9b9b4581f4 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -649,7 +649,7 @@ ptrdiff_t os_write(const int fd, const char *const buf, const size_t size, /// @param path Path of file to be copied /// @param path_new Path of new file /// @param flags Bitwise OR of flags defined in -/// @return libuv error code on error +/// @return 0 on success, or libuv error code on failure. int os_copy(const char *path, const char *new_path, int flags) { int r; From 646c3423dd580aebb677d9a3fe0ed26f74f97e31 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 20 May 2019 22:43:10 +0200 Subject: [PATCH 09/10] fileio: set group of backup file Restores code removed in #9709. uv_fs_copyfile() copies the perm bits but not the group name. https://github.com/libuv/libuv/pull/1547 ref #9709 ref #8288 --- src/nvim/fileio.c | 17 +++++++++++++++++ src/nvim/os/fs.c | 20 ++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 55463bdf30..15d7a885d5 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2868,6 +2868,23 @@ buf_write ( /* remove old backup, if present */ os_remove((char *)backup); + // set file protection same as original file, but + // strip s-bit. + (void)os_setperm((const char *)backup, perm & 0777); + +#ifdef UNIX + // + // Try to set the group of the backup same as the original file. If + // this fails, set the protection bits for the group same as the + // protection bits for others. + // + if (file_info_new.stat.st_gid != file_info_old.stat.st_gid + && os_chown((char *)backup, -1, file_info_old.stat.st_gid) != 0) { + os_setperm((const char *)backup, + (perm & 0707) | ((perm & 07) << 3)); + } +#endif + // copy the file if (os_copy((char *)fname, (char *)backup, UV_FS_COPYFILE_FICLONE) != 0) { diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 8c7dfcdee7..d1d088cf24 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -712,12 +712,24 @@ int os_setperm(const char *const name, int perm) return (r == kLibuvSuccess ? OK : FAIL); } -/// Changes the ownership of the file referred to by the open file descriptor. +/// Changes the owner and group of a file, like chown(2). /// -/// @return `0` on success, a libuv error code on failure. +/// @return 0 on success, or libuv error code on failure. /// -/// @note If the `owner` or `group` is specified as `-1`, then that ID is not -/// changed. +/// @note If `owner` or `group` is -1, then that ID is not changed. +int os_chown(const char* path, uv_uid_t owner, uv_gid_t group) +{ + int r; + RUN_UV_FS_FUNC(r, uv_fs_chown, path, owner, group, NULL); + return r; +} + +/// Changes the owner and group of the file referred to by the open file +/// descriptor, like fchown(2). +/// +/// @return 0 on success, or libuv error code on failure. +/// +/// @note If `owner` or `group` is -1, then that ID is not changed. int os_fchown(int fd, uv_uid_t owner, uv_gid_t group) { int r; From 5b04a4fa09e0ee09678aec23b1d0233e7c25e3e6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 20 May 2019 23:06:14 +0200 Subject: [PATCH 10/10] lua/shared: share trim() impl --- runtime/doc/if_lua.txt | 31 ++++++++++++++++--------------- runtime/lua/vim/shared.lua | 11 +++++++++++ src/nvim/lua/vim.lua | 12 ++++-------- src/nvim/os/fs.c | 2 +- test/helpers.lua | 5 ----- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt index 7f90074ff0..e2d1f0f675 100644 --- a/runtime/doc/if_lua.txt +++ b/runtime/doc/if_lua.txt @@ -374,11 +374,6 @@ For example, to use the "nvim_get_current_line()" API function, call ------------------------------------------------------------------------------ VIM *lua-util* -vim.inspect({object}, {options}) *vim.inspect* - Return a human-readable representation of the passed object. See - https://github.com/kikito/inspect.lua - for details and possible options. - vim.stricmp(a, b) *lua-vim.stricmp* Function used for case-insensitive string comparison. Takes two string arguments and returns 0, 1 or -1 if strings are equal, a is @@ -422,18 +417,11 @@ vim.types *lua-vim.types* ============================================================================== Lua module: vim *lua-vim* -trim({s}) *vim.trim()* - Trim whitespace (Lua pattern "%%s") from both sides of a - string. - - Parameters: ~ - {s} String to trim - - Return: ~ - String with whitespace removed from its beginning and end +inspect({object}, {options}) *vim.inspect()* + Return a human-readable representation of the given object. See also: ~ - https://www.lua.org/pil/20.2.html + https://github.com/kikito/inspect.lua @@ -521,4 +509,17 @@ tbl_flatten({t}) *vim.tbl_flatten()* Return: ~ Flattened copy of the given list-like table. +trim({s}) *vim.trim()* + Trim whitespace (Lua pattern "%%s") from both sides of a + string. + + Parameters: ~ + {s} String to trim + + Return: ~ + String with whitespace removed from its beginning and end + + See also: ~ + https://www.lua.org/pil/20.2.html + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 07145c6e3f..1038a95dd3 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -168,6 +168,16 @@ local function tbl_flatten(t) return result end +--- Trim whitespace (Lua pattern "%%s") from both sides of a string. +--- +--@see https://www.lua.org/pil/20.2.html +--@param s String to trim +--@returns String with whitespace removed from its beginning and end +local function trim(s) + assert(type(s) == 'string', 'Only strings can be trimmed') + return s:match('^%s*(.*%S)') or '' +end + local module = { deepcopy = deepcopy, gsplit = gsplit, @@ -175,5 +185,6 @@ local module = { tbl_contains = tbl_contains, tbl_extend = tbl_extend, tbl_flatten = tbl_flatten, + trim = trim, } return module diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua index 9cd8e232d5..848bccaae6 100644 --- a/src/nvim/lua/vim.lua +++ b/src/nvim/lua/vim.lua @@ -154,14 +154,11 @@ local function _update_package_paths() last_nvim_paths = cur_nvim_paths end ---- Trim whitespace (Lua pattern "%%s") from both sides of a string. +--- Return a human-readable representation of the given object. --- ---@see https://www.lua.org/pil/20.2.html ---@param s String to trim ---@returns String with whitespace removed from its beginning and end -local function trim(s) - assert(type(s) == 'string', 'Only strings can be trimmed') - return s:match('^%s*(.*%S)') or '' +--@see https://github.com/kikito/inspect.lua +local function inspect(object, options) -- luacheck: no unused + error(object, options) -- Stub for gen_vimdoc.py end local function __index(t, key) @@ -180,7 +177,6 @@ local module = { _os_proc_children = _os_proc_children, _os_proc_info = _os_proc_info, _system = _system, - trim = trim, } setmetatable(module, { diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index d1d088cf24..d5500b230c 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -717,7 +717,7 @@ int os_setperm(const char *const name, int perm) /// @return 0 on success, or libuv error code on failure. /// /// @note If `owner` or `group` is -1, then that ID is not changed. -int os_chown(const char* path, uv_uid_t owner, uv_gid_t group) +int os_chown(const char *path, uv_uid_t owner, uv_gid_t group) { int r; RUN_UV_FS_FUNC(r, uv_fs_chown, path, owner, group, NULL); diff --git a/test/helpers.lua b/test/helpers.lua index 2a6285e685..3311f3ef97 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -697,10 +697,6 @@ local function read_nvim_log() return log end -local function trim(s) - return s:match('^%s*(.*%S)') or '' -end - local module = { REMOVE_THIS = REMOVE_THIS, argss_to_cmd = argss_to_cmd, @@ -740,7 +736,6 @@ local module = { updated = updated, which = which, write_file = write_file, - trim = trim, } module = shared.tbl_extend('error', module, Paths, shared)