| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem: getfsize() checks the file type twice.
Solution: Use S_ISDIR macro instead of calling mch_isdir()
(Yasuhiro Matsumoto).
On MS-Windows: 40.8 us -> 26.6 us for a file, 41.1 us -> 25.3 us for
a directory.
closes: vim/vim#21448
Assisted-by: AI
https://github.com/vim/vim/commit/ea1e40e5e06b1a6a5abebe77223f4a7e36930a87
Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
Problem: Vim9: globpath() doesnot take "true" as argument.
Solution: Use tv_get_bool_chk(). (closes vim/vim#6821)
https://github.com/vim/vim/commit/f966ce5ea24748eed10f708d4f828be44887a559
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
|
|
|
|
|
|
|
| |
Problem: Vim9: glob() doesnot take "true" as argument.
Solution: Use tv_get_bool_chk(). (closes vim/vim#6821)
https://github.com/vim/vim/commit/5892ea151197c8a6363c7ce2322d84277b97353e
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
Redudant code
Solution:
Add `path_fold_char()` to normalize path sep.
Refactor `pathcmp()` and `path_fnamencmp()` into `path_cmp`.
| feature | pathcmp | path_fnamencmp | path_cmp(now) |
| ------------------------ | -------------- | -------------- | ------------- |
| case folding | `mb_toupper()` | `utf_fold()` | `utf_fold()` |
| consults fileignorecase | ✅ | ✅ | `ic` param |
| `maxlen` | ✅ | ✅ | ✅ |
| `/` == `\` | ✅ | ✅ | ✅ |
| MSWIN drive letter | ❌ | ✅ | ✅ |
| sep affects sorting | ✅ | ❌ | ✅ |
| ignores a trailing slash | ✅ | ❌ | ✅ |
Refactor `path_fnamecmp` and `path_full_compare` into `path_equal`,
with flags controlling "no filesystem" comparison (i.e. `path_cmp`), env
variables expansion, absolute path resolution and filesystem access.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
- buf-local CWD scope is lower priority than :lcd, which is weird.
```
win > buf > tab > global
```
- No way to clear current CWD at a given scope.
Solution:
- Rerrange scope precedence to:
```
buf > win > tab > global
```
- Introduce "bang" variants (`:bcd!`/`:lcd!`/`:tcd!`) which clears the
local CWD for the given scope.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
- Explicit `:bcd` (etc.) persists from `nvim_buf_call()` but not from an
autocmd handler targeting a hidden buf (`LspAttach`, `TermRequest`, …),
which needs a `vim.schedule()` workaround.
- `vim._with()` is supposed to work as a "sandbox", discarding
side-effects, but it leaks CWD changes: `:lcd` from a `win` context,
any chdir from a visible-buffer context.
Solution:
- Explicit :cd/:tcd/:bcd during a temp context persists by default.
- "Ambient" directory changes ('autochdir', existing win-local CWD,
etc.) are still undone, as before.
- Add `kCtxKeepDirs`: snapshot/restore the target's full CWD state
(w/b/tp-local, global, cwd). Used by `vim._with()` and `'inccommand'`,
which must not leak state.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
No way to set a buffer-local directory.
Use-cases:
- "Root dir" for LSP (and the "project" concept).
- `:terminal` OSC 7
Solution:
Add `:bcd` command.
- Extend `getcwd()` to take a third arg; `getcwd(-1, -1, bunfr)` returns
the buffer-local working directory.
- Buffer-local directories have less priority than window-local
ones, and more priority than tab-local ones.
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
/src/nvim/ex_docmd.c: 5033 in ex_restart()
5027 // The address after --listen may be in use by the current server.
5028 if (i > 0 && strequal(arg, "--listen")) {
5029 const listitem_T *next_li = li->li_next;
5030 if (next_li != NULL) {
5031 const char *addr = tv_get_string(TV_LIST_ITEM_TV(next_li));
5032 if (strstr(addr, ":") || strstr(addr, "/") || strstr(addr, "\\")) {
>>> CID 649201: Resource leaks (RESOURCE_LEAK)
>>> Overwriting "listen_arg" in "listen_arg = xstrdup(addr)" leaks the storage that "listen_arg" points to.
5033 listen_arg = TO_SLASH_SAVE(addr);
5034 #ifdef MSWIN
5035 // On Windows, don't pass --listen to new server (named pipe can't be reused immediately).
5036 // Instead pass the address via RPC; new server rebinds after startup.
5037 li = next_li;
5038 continue;
*** CID 649200: Memory - illegal accesses (USE_AFTER_FREE)
/src/nvim/eval/fs.c: 228 in modify_fname()
222
223 // ":h" - head, remove "/file_name", can be repeated
224 // Don't remove the logical root, see `FileInfo`.
225 while (src[*usedlen] == ':' && src[*usedlen + 1] == 'h') {
226 valid |= VALID_HEAD;
227 *usedlen += 2;
>>> CID 649200: Memory - illegal accesses (USE_AFTER_FREE)
>>> Using freed pointer "s".
228 while (tail > s && after_pathsep(s, tail)) {
229 MB_PTR_BACK(*fnamep, tail);
230 }
231 *fnamelen = tail <= s ? (size_t)(s - *fnamep) : (size_t)(tail - *fnamep);
232 if (*fnamelen == 0) {
233 // Result is empty. Turn it into "." to make ":cd %:h" work.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
Continue separators normalization, and try to keep it at the
nvim <-> external boundary, e.g., `fn.xxx`, `api.xxx`, `:xxx`
Solution:
some key changes
- normalize `$HOME-windows`
- normalize entry points of changing directory
- `nvim_set_current_dir()`, `chdir()`
- normalize the named pipe
- `--listen` arg, `--server` arg, `:restart`
- `serverstart()`, `sockconnect()`, `serverstop()`
- make `expand()` respect 'shellslash' again
- clean up `did_set_shellslash`
- replace `forward_slash` with `TO_SLASH`
- remove obsolete `TMP_PATHSEPSTR`
- remove `slash_adjust` in `do_autocmd_dirchanged`?
- make `fnamemodify()` always return `/` (except when substituting
separators via `:s`, `:gs` ?)
Note:
- these funcs still apply `slash_adjust` on return, as before:
`:pwd`, `chdir()`, `exepath()`, `getcwd()`
- these funcs alwarys return `/`, unlike before the normalization PRs
- `getcompletion()`, `finddir()`, `findfile()`
Also
- clean up code, comments, formatting and tests
- move `TO_SLASH` from `f_chdir` to `changedir_func`
- move `TO_SLASH` from `f_bufadd` to `buflist_new`
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
|
| |
|
|
| |
related: fb6aeaba2d3a
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
On Windows, `fnamemodify('//foo/C$', ':h')` incorrectly removes `C$`
as a regular file name and returns `//foo`. However, this is a valid
UNC path, `foo` is a server name and `C$` is a share name.
The correct result should be `//foo/C$`.
Solution:
Extend `os_fileinfo2` and `FileInfo` with `prefix_off`, `rest_off` to
identify path types and logical root boundaries. ':h' can use this info
to prevent traversing past the logical root.
Examples:
/foo => /
//foo => // (POSIX)
//foo/bar => //foo (POSIX)
//server/share/foo => //server/share/ (Windows)
C:/foo => C:/
//?/C:/foo => //?/C:/
Co-authored-by: Barrett Ruth <br@barrettruth.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem: Some functions use any value as a string.
Solution: Check that the value is a non-empty string.
-----
Vim9 remains N/A.
5ccc79e880d5913f092e041f1a67530c1d2d6728 ported relevant changes.
https://github.com/vim/vim/commit/7bb4e74c38642682cfdd0cb4052adfa5efdd7dd1
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem: home_replace() function can be improved
Solution: Refactor home_replace() to return the length of the string
(John Marriott).
In addition:
- in function set_b0_fname() move ulen into the block where it is used.
- In function findswapname() rework logic around displaying "swap file
already exists" dialogue so that literal message text is set once.
closes: vim/vim#20249
https://github.com/vim/vim/commit/a0931a90eeee6692556f330b5ba1fb413f9ea85d
Co-authored-by: John Marriott <basilisk@internode.on.net>
|
| |
|
|
|
| |
Problem: `fnamemodify(..., ':h')` mishandles POSIX leading slash runs longer than `//`.
Solution: Collapse those slash runs to `/` before computing the head.
|
| |
|
|
|
|
|
|
|
|
|
| |
Problem: some functions can be run from the sandbox
Solution: Block them, so they are not accessible from a modeline
(q1uf3ng)
closes: vim/vim#19975
https://github.com/vim/vim/commit/fcc4276db31bc35239186e62921b4ff5a15fb18e
Co-authored-by: q1uf3ng <q1uf3ng@protone.me>
|
| |
|
|
|
|
|
|
| |
Problem:
`gx` relies on `exepath` to get the fullpath of `cmd.exe`,
and that path must use `\`; otherwise, luv's spawn will fail.
Solution:
Revert `slash_adjust` in `exepath`, so that it still respects 'shellslash'
|
| |
|
|
|
|
|
|
|
|
|
| |
Problem:
- write_blob, write_string dereference args which may be NULL.
- `writefile(v:_null_blob, …)` fails.
Solution:
- Fix the annotation.
- Handle null blob.
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
On Windows, path separators may become inconsistent for various reasons,
which makes normalization quite painful.
Solution:
Normalize paths to `/` at the entry boundaries and always use it
internally, converting back only in rare cases where `\` is really
needed (e.g. cmd.exe/bat scripts?).
This is the first commit in a series of incremental steps.
Note:
* some funcs won't respect shellslash. e.g. `expand/fnamemodify`
* some funcs still respect shellslash, but will be updated in a follow
PR. e.g. `ex_pwd/f_chdir/f_getcwd`
* uv's built-in funcs always return `\`. e.g. `uv.cwd/uv.exepath`
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
|
| |
|
|
|
|
|
| |
Problem:
vim.fn.writefile() treats Lua strings as Vimscript strings instead of a "binary clean" string.
Solution:
Treat Lua-originated strings as blob data.
|
| |
|
|
|
| |
- `src/nvim/ex_cmds_defs.h`: use "U" instead of "u" per
`readability-uppercase-literal-suffix`
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Problem: Inefficient use of ga_concat()
Solution: Use ga_concat_len() when the length is already known to avoid
use of strlen() (John Marriott).
closes: vim/vim#19422
https://github.com/vim/vim/commit/ed202035b1904c84d92adb76d7e1a95b7540e048
Co-authored-by: John Marriott <basilisk@internode.on.net>
Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
Problem: MS-Windows: some style issues with patch v9.1.1646
Solution: Fix typose and code style issues (zeertzjq).
closes: vim/vim#18036
https://github.com/vim/vim/commit/14afa278c1bcb2df51b647ffda2821c5294eb7ff
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Problem: MS-Windows: completion cannot handle implicit drive letters
Solution: Consider paths like \folder and /folder as absolute
(Miguel Barro).
closes: vim/vim#17829
https://github.com/vim/vim/commit/a2f13bf782f723e116c5d4cc7d79a23e918a24db
Co-authored-by: Miguel Barro <miguel.barro@live.com>
|
| |
|
|
|
|
|
|
| |
Problem: Code for handling file names is spread out.
Solution: Move code to new filepath.c file. Graduate FEAT_MODIFY_FNAME.
https://github.com/vim/vim/commit/b005cd80cfda591be95146024d9b97eef383500f
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
file (#35968)
Problem: Code for handling v: variables in generic eval file.
Solution: Move v: variables to evalvars.c. (Yegappan Lakshmanan,
closes vim/vim#4872)
https://github.com/vim/vim/commit/e5cdf153bcb348c68011b308c8988cea42d6ddeb
Remove direct reference to "vimvars" for following functions:
- assert_error()
- get_vim_var_nr()
- get_vim_var_list()
- get_vim_var_dict()
- get_vim_var_str()
- set_cmdarg()
- set_reg_var()
- set_vcount()
- set_vexception()
- set_vthrowpoint()
- set_vim_var_bool()
- set_vim_var_dict()
- set_vim_var_list()
- set_vim_var_nr()
- set_vim_var_special()
- set_vim_var_string()
- set_vim_var_type()
Reorder functions based on v8.2.4930 for
eval_one_expr_in_str() and eval_all_expr_in_str().
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
| |
|
|
|
|
| |
This adds a missing change from Vim patch 7.4.279.
N/A patch:
vim-patch:9.1.1691: over-allocation in ga_concat_strings()
|
| |
|
|
|
|
|
|
|
| |
These are not needed after #35129 but making uncrustify still play nice
with them was a bit tricky.
Unfortunately `uncrustify --update-config-with-doc` breaks strings
with backslashes. This issue has been reported upstream,
and in the meanwhile auto-update on every single run has been disabled.
|
| |
|
|
|
|
|
|
|
|
| |
Problem: Cannot specify scope for chdir()
Solution: Add optional scope argument (kuuote)
closes: vim/vim#17888
https://github.com/vim/vim/commit/8a65a49d509d5a9dd5759a4287969896e8941c10
Co-authored-by: kuuote <znmxodq1@gmail.com>
|
| |
|
|
|
|
|
|
|
|
| |
Problem: Checking for absolute path is not trivial.
Solution: Add isabsolutepath(). (closes vim/vim#10303)
https://github.com/vim/vim/commit/dca1d40cd0f2af0755519e7028378bd3c8fefd31
vim-patch:8a3b805c6c9c
Co-authored-by: LemonBoy <thatlemon@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
Problem: missing filecopy() function
Solution: implement filecopy() Vim script function
(Shougo Matsushita)
closes: vim/vim#12346
https://github.com/vim/vim/commit/60c8743ab6c90e402e6ed49d27455ef7e5698abe
Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
|
|
In Vim a lot of filesystem functions have been moved to filepath.c.
However, some of these functions actually deal with file contents, and
Nvim's filesystem-related functions are spread out in a different way.
Therefore, it's better to use a different file for these functions.
|