aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds2.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-08 11:01:46 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-07-08 11:11:22 +0800
commita890c019a3689fc15d8a5710cfc0cb92c5ac041d (patch)
tree39e3f979e68d8b6f96f4d4dd9b8c9396e953ee02 /src/nvim/ex_cmds2.c
parentca64b589cd74e9f6bd369286a415711ec7197082 (diff)
downloadrneovim-a890c019a3689fc15d8a5710cfc0cb92c5ac041d.tar.gz
rneovim-a890c019a3689fc15d8a5710cfc0cb92c5ac041d.tar.bz2
rneovim-a890c019a3689fc15d8a5710cfc0cb92c5ac041d.zip
vim-patch:8.2.0132: script may be re-used when deleting and creating a new one
Problem: Script may be re-used when deleting and creating a new one. Solution: When the inode matches, also check the file name. https://github.com/vim/vim/commit/ca33eb256eb910af05e8c9852bc9f716cece1f5c
Diffstat (limited to 'src/nvim/ex_cmds2.c')
-rw-r--r--src/nvim/ex_cmds2.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index defe22ea9a..82970e2566 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -2161,16 +2161,19 @@ scriptitem_T *get_current_script_id(char_u *fname, sctx_T *ret_sctx)
bool file_id_ok = os_fileid((char *)fname, &file_id);
assert(script_items.ga_len >= 0);
- for (script_sctx.sc_sid = script_items.ga_len; script_sctx.sc_sid > 0;
- script_sctx.sc_sid--) {
+ for (script_sctx.sc_sid = script_items.ga_len; script_sctx.sc_sid > 0; script_sctx.sc_sid--) {
si = &SCRIPT_ITEM(script_sctx.sc_sid);
- // Compare dev/ino when possible, it catches symbolic links.
- // Also compare file names, the inode may change when the file was edited.
- bool file_id_equal = file_id_ok && si->file_id_valid
- && os_fileid_equal(&(si->file_id), &file_id);
- if (si->sn_name != NULL
- && (file_id_equal || FNAMECMP(si->sn_name, fname) == 0)) {
- break;
+ if (si->sn_name != NULL) {
+ // Compare dev/ino when possible, it catches symbolic links.
+ // Also compare file names, the inode may change when the file was
+ // edited or it may be re-used for another script (esp. in tests).
+ if (file_id_ok && si->file_id_valid && !os_fileid_equal(&(si->file_id), &file_id)) {
+ continue;
+ }
+ if (FNAMECMP(si->sn_name, fname) == 0) {
+ // Found it!
+ break;
+ }
}
}
if (script_sctx.sc_sid == 0) {