From c8c930ea785aa393ebc819139913a9e05f0ccd45 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 10:24:46 +0100 Subject: refactor: reduce scope of locals as per the style guide (#22206) --- src/nvim/ex_session.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 3de5e1db52..8e3e68d9b7 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -65,10 +65,10 @@ static int put_view_curpos(FILE *fd, const win_T *wp, char *spaces) static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin) { - int n = 0; win_T *wp; if (restore_size && (ssop_flags & SSOP_WINSIZE)) { + int n = 0; for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) { if (!ses_do_win(wp)) { continue; @@ -218,14 +218,13 @@ static int ses_do_win(win_T *wp) static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, int fullname, unsigned *flagp) { char *buf = NULL; - char *s; if (fprintf(fd, "%s\n%s\n", cmd, "%argdel") < 0) { return FAIL; } for (int i = 0; i < gap->ga_len; i++) { // NULL file names are skipped (only happens when out of memory). - s = alist_name(&((aentry_T *)gap->ga_data)[i]); + char *s = alist_name(&((aentry_T *)gap->ga_data)[i]); if (s != NULL) { if (fullname) { buf = xmalloc(MAXPATHL); @@ -551,7 +550,6 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr static int makeopens(FILE *fd, char *dirnow) { int only_save_windows = true; - int nr; int restore_size = true; win_T *wp; char *sname; @@ -753,11 +751,9 @@ static int makeopens(FILE *fd, char *dirnow) PUTLINE_FAIL("let &splitright = s:save_splitright"); } - // // Check if window sizes can be restored (no windows omitted). // Remember the window number of the current window after restoring. - // - nr = 0; + int nr = 0; for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) { if (ses_do_win(wp)) { nr++; @@ -927,11 +923,9 @@ void ex_loadview(exarg_T *eap) void ex_mkrc(exarg_T *eap) { FILE *fd; - int failed = false; int view_session = false; // :mkview, :mksession int using_vdir = false; // using 'viewdir'? char *viewFile = NULL; - unsigned *flagp; if (eap->cmdidx == CMD_mksession || eap->cmdidx == CMD_mkview) { view_session = true; @@ -970,6 +964,8 @@ void ex_mkrc(exarg_T *eap) fd = open_exfile(fname, eap->forceit, WRITEBIN); if (fd != NULL) { + int failed = false; + unsigned *flagp; if (eap->cmdidx == CMD_mkview) { flagp = &vop_flags; } else { -- cgit From 7dc9182cf0b27cbfb4e289db55dd7b02998ef5c8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Mar 2023 21:29:25 +0800 Subject: vim-patch:8.2.1398: autoload script sourced twice if sourced directly (#22622) Problem: Autoload script sourced twice if sourced directly. Solution: Do not source an autoload script again. (issue vim/vim#6644) https://github.com/vim/vim/commit/daa2f36573db3e1df7eb1fdbc3a09a2815644048 Cherry-pick ret_sid changes from patch 8.2.0149. Use do_in_runtimepath() as that's what source_runtime() calls in Nvim. Co-authored-by: Bram Moolenaar --- src/nvim/ex_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 8e3e68d9b7..855a5f7538 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -909,7 +909,7 @@ void ex_loadview(exarg_T *eap) return; } - if (do_source(fname, false, DOSO_NONE) == FAIL) { + if (do_source(fname, false, DOSO_NONE, NULL) == FAIL) { semsg(_(e_notopen), fname); } xfree(fname); -- cgit From d5f6176e6dc4b4e12fc5061ca6e87f4af533e46a Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Sat, 1 Apr 2023 02:49:51 +0200 Subject: refactor: add const and remove unnecessary casts (#22841) --- src/nvim/ex_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 855a5f7538..d47d40cbee 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -959,7 +959,7 @@ void ex_mkrc(exarg_T *eap) // When using 'viewdir' may have to create the directory. if (using_vdir && !os_isdir(p_vdir)) { - vim_mkdir_emsg((const char *)p_vdir, 0755); + vim_mkdir_emsg(p_vdir, 0755); } fd = open_exfile(fname, eap->forceit, WRITEBIN); -- cgit From 820522d685e2794c638144a88ceee50d53bdc104 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 3 Sep 2023 14:00:45 +0800 Subject: refactor(ex_session.c): remove unnecessary char -> int -> char cast The two calls to get_view_file() both pass a char in a string, and get_view_file() assigns it to a char in a string. --- src/nvim/ex_session.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index d47d40cbee..e2a4f73840 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -1080,7 +1080,7 @@ void ex_mkrc(exarg_T *eap) } /// @return the name of the view file for the current buffer. -static char *get_view_file(int c) +static char *get_view_file(char c) { if (curbuf->b_ffname == NULL) { emsg(_(e_noname)); @@ -1119,8 +1119,7 @@ static char *get_view_file(int c) } } *s++ = '='; - assert(c >= CHAR_MIN && c <= CHAR_MAX); - *s++ = (char)c; + *s++ = c; xstrlcpy(s, ".vim", 5); xfree(sname); -- cgit From cf8b2c0e74fd5e723b0c15c2ce84e6900fd322d3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 12:05:28 +0800 Subject: build(iwyu): add a few more _defs.h mappings (#25435) --- src/nvim/ex_session.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index e2a4f73840..220cd4236c 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -7,9 +7,7 @@ // :mkview // :mksession -#include #include -#include #include #include #include @@ -30,7 +28,6 @@ #include "nvim/globals.h" #include "nvim/macros.h" #include "nvim/mapping.h" -#include "nvim/mark_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" -- cgit From dc6d0d2daf69e2fdadda81feb97906dbc962a239 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 14:41:34 +0800 Subject: refactor: reorganize option header files (#25437) - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other --- src/nvim/ex_session.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 220cd4236c..bbe57b486d 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -31,6 +31,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/pos.h" -- cgit From acc646ad8fc3ef11fcc63b69f3d8484e4a91accd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/ex_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index bbe57b486d..32235e158b 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -629,7 +629,7 @@ static int makeopens(FILE *fd, char *dirnow) && buf->b_p_bl) { if (fprintf(fd, "badd +%" PRId64 " ", buf->b_wininfo == NULL - ? (int64_t)1L + ? 1 : (int64_t)buf->b_wininfo->wi_mark.mark.lnum) < 0 || ses_fname(fd, buf, &ssop_flags, true) == FAIL) { return FAIL; -- cgit From 353a4be7e84fdc101318215bdcc8a7e780d737fe Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 13:13:58 +0100 Subject: build: remove PVS We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable. --- src/nvim/ex_session.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 32235e158b..88c690a6a9 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Functions for creating a session file, i.e. implementing: // :mkexrc // :mkvimrc -- cgit From 538749410b8eae6d3c5b2c06c230132a6d7127ac Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 13:25:32 +0800 Subject: vim-patch:partial:8.1.1218: cannot set a directory for a tab page Problem: Cannot set a directory for a tab page. Solution: Add the tab-local directory. (Yegappan Lakshmanan, closes vim/vim#4212) https://github.com/vim/vim/commit/00aa069db8132851a91cfc5ca7f58ef945c75c73 Session-related changes only. Co-authored-by: Bram Moolenaar --- src/nvim/ex_session.c | 53 +++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 88c690a6a9..63dfdbc078 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -324,9 +324,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr // when 'viewoptions' contains "cursor". do_cursor = (flagp == &ssop_flags || *flagp & SSOP_CURSOR); - // // Local argument list. - // if (wp->w_alist == &global_alist) { PUTLINE_FAIL("argglobal"); } else { @@ -419,21 +417,17 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr } } - // // Local mappings and abbreviations. - // if ((*flagp & (SSOP_OPTIONS | SSOP_LOCALOPTIONS)) && makemap(fd, wp->w_buffer) == FAIL) { return FAIL; } - // // Local options. Need to go to the window temporarily. // Store only local values when using ":mkview" and when ":mksession" is // used and 'sessionoptions' doesn't include "nvim/options". // Some folding options are always stored when "folds" is included, // otherwise the folds would not be restored correctly. - // save_curwin = curwin; curwin = wp; curbuf = curwin->w_buffer; @@ -451,9 +445,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr return FAIL; } - // // Save Folds when 'buftype' is empty and for help files. - // if ((*flagp & SSOP_FOLDS) && wp->w_buffer->b_ffname != NULL && (bt_normal(wp->w_buffer) @@ -463,9 +455,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr } } - // // Set the cursor after creating folds, since that moves the cursor. - // if (do_cursor) { // Restore the cursor line in the file and relatively in the // window. Don't use "G", it changes the jumplist. @@ -516,10 +506,8 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr } } - // // Local directory, if the current flag is not view options or the "curdir" // option is included. - // if (wp->w_localdir != NULL && (flagp != &vop_flags || (*flagp & SSOP_CURDIR))) { if (fputs("lcd ", fd) < 0 @@ -574,9 +562,7 @@ static int makeopens(FILE *fd, char *dirnow) return FAIL; } - // // Now a :cd command to the session directory or the current directory - // if (ssop_flags & SSOP_SESDIR) { PUTLINE_FAIL("exe \"cd \" . escape(expand(\":p:h\"), ' ')"); } else if (ssop_flags & SSOP_CURDIR) { @@ -658,11 +644,9 @@ static int makeopens(FILE *fd, char *dirnow) restore_stal = true; } - // // For each tab: // - Put windows for each tab, when "tabpages" is in 'sessionoptions'. // - Don't use goto_tabpage(), it may change CWD and trigger autocommands. - // tab_firstwin = firstwin; // First window in tab page "tabnr". tab_topframe = topframe; if ((ssop_flags & SSOP_TABPAGES)) { @@ -703,11 +687,9 @@ static int makeopens(FILE *fd, char *dirnow) } } - // // Before creating the window layout, try loading one file. If this // is aborted we don't end up with a number of useless windows. // This may have side effects! (e.g., compressed or network file). - // for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) { if (ses_do_win(wp) && wp->w_buffer->b_ffname != NULL @@ -785,9 +767,19 @@ static int makeopens(FILE *fd, char *dirnow) return FAIL; } - // + // Restore the tab-local working directory if specified + // Do this before the windows, so that the window-local directory can + // override the tab-local directory. + if (tp != NULL && tp->tp_localdir != NULL && (ssop_flags & SSOP_CURDIR)) { + if (fputs("tcd ", fd) < 0 + || ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL + || put_eol(fd) == FAIL) { + return FAIL; + } + did_lcd = true; + } + // Restore the view of the window (options, file, cursor, etc.). - // for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) { if (!ses_do_win(wp)) { continue; @@ -807,31 +799,17 @@ static int makeopens(FILE *fd, char *dirnow) // "tabedit". cur_arg_idx = next_arg_idx; - // // Restore cursor to the current window if it's not the first one. - // if (cnr > 1 && (fprintf(fd, "%dwincmd w\n", cnr) < 0)) { return FAIL; } - // // Restore window sizes again after jumping around in windows, because // the current window has a minimum size while others may not. - // if (nr > 1 && ses_winsizes(fd, restore_size, tab_firstwin) == FAIL) { return FAIL; } - // Take care of tab-local working directories if applicable - if (tp->tp_localdir) { - if (fputs("if exists(':tcd') == 2 | tcd ", fd) < 0 - || ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL - || fputs(" | endif\n", fd) < 0) { - return FAIL; - } - did_lcd = true; - } - // Don't continue in another tab page when doing only the current one // or when at the last tab page. if (!(ssop_flags & SSOP_TABPAGES)) { @@ -848,9 +826,7 @@ static int makeopens(FILE *fd, char *dirnow) return FAIL; } - // // Wipe out an empty unnamed buffer we started in. - // if (fprintf(fd, "%s", "if exists('s:wipebuf') " "&& len(win_findbuf(s:wipebuf)) == 0 " @@ -882,9 +858,7 @@ static int makeopens(FILE *fd, char *dirnow) PUTLINE_FAIL("let &winminwidth = s:save_winminwidth"); } - // // Lastly, execute the x.vim file if it exists. - // if (fprintf(fd, "%s", "let s:sx = expand(\":p:r\").\"x.vim\"\n" "if filereadable(s:sx)\n" @@ -999,9 +973,8 @@ void ex_mkrc(exarg_T *eap) char *dirnow; // current directory dirnow = xmalloc(MAXPATHL); - // + // Change to session file's dir. - // if (os_dirname(dirnow, MAXPATHL) == FAIL || os_chdir(dirnow) != 0) { *dirnow = NUL; -- cgit From c23c44f845c8d357093d87f6e2e5636d2a11a8fb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 13:53:21 +0800 Subject: vim-patch:8.2.4850: mksession mixes up "tabpages" and "curdir" arguments Problem: Mksession mixes up "tabpages" and "curdir" arguments. Solution: Correct logic for storing tabpage in session. (closes vim/vim#10312) https://github.com/vim/vim/commit/d7c9564d8d24343f2e27205633032dd6ebe5232c Co-authored-by: LemonBoy --- src/nvim/ex_session.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 63dfdbc078..3807436efb 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -537,7 +537,6 @@ static int makeopens(FILE *fd, char *dirnow) win_T *wp; char *sname; win_T *edited_win = NULL; - int tabnr; win_T *tab_firstwin; frame_T *tab_topframe; int cur_arg_idx = 0; @@ -644,14 +643,10 @@ static int makeopens(FILE *fd, char *dirnow) restore_stal = true; } - // For each tab: - // - Put windows for each tab, when "tabpages" is in 'sessionoptions'. - // - Don't use goto_tabpage(), it may change CWD and trigger autocommands. - tab_firstwin = firstwin; // First window in tab page "tabnr". - tab_topframe = topframe; if ((ssop_flags & SSOP_TABPAGES)) { - // Similar to ses_win_rec() below, populate the tab pages first so - // later local options won't be copied to the new tabs. + // "tabpages" is in 'sessionoptions': Similar to ses_win_rec() below, + // populate the tab pages first so later local options won't be copied + // to the new tabs. FOR_ALL_TABS(tp) { // Use `bufhidden=wipe` to remove empty "placeholder" buffers once // they are not needed. This prevents creating extra buffers (see @@ -665,15 +660,17 @@ static int makeopens(FILE *fd, char *dirnow) return FAIL; } } - for (tabnr = 1;; tabnr++) { - tabpage_T *tp = find_tabpage(tabnr); - if (tp == NULL) { - break; // done all tab pages - } + // Assume "tabpages" is in 'sessionoptions'. If not then we only do + // "curtab" and bail out of the loop. + FOR_ALL_TABS(tp) { bool need_tabnext = false; int cnr = 1; + // May repeat putting Windows for each tab, when "tabpages" is in + // 'sessionoptions'. + // Don't use goto_tabpage(), it may change directory and trigger + // autocommands. if ((ssop_flags & SSOP_TABPAGES)) { if (tp == curtab) { tab_firstwin = firstwin; @@ -682,9 +679,13 @@ static int makeopens(FILE *fd, char *dirnow) tab_firstwin = tp->tp_firstwin; tab_topframe = tp->tp_topframe; } - if (tabnr > 1) { + if (tp != first_tabpage) { need_tabnext = true; } + } else { + tp = curtab; + tab_firstwin = firstwin; + tab_topframe = topframe; } // Before creating the window layout, try loading one file. If this @@ -770,7 +771,7 @@ static int makeopens(FILE *fd, char *dirnow) // Restore the tab-local working directory if specified // Do this before the windows, so that the window-local directory can // override the tab-local directory. - if (tp != NULL && tp->tp_localdir != NULL && (ssop_flags & SSOP_CURDIR)) { + if ((ssop_flags & SSOP_CURDIR) && tp->tp_localdir != NULL) { if (fputs("tcd ", fd) < 0 || ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL || put_eol(fd) == FAIL) { -- cgit From 28f4f3c48498086307ed825d1761edb5789ca0e8 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 15:54:54 +0100 Subject: refactor: follow style guide - reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values --- src/nvim/ex_session.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 3807436efb..aa85696b51 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -60,11 +60,9 @@ static int put_view_curpos(FILE *fd, const win_T *wp, char *spaces) static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin) { - win_T *wp; - if (restore_size && (ssop_flags & SSOP_WINSIZE)) { int n = 0; - for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) { + for (win_T *wp = tab_firstwin; wp != NULL; wp = wp->w_next) { if (!ses_do_win(wp)) { continue; } @@ -104,7 +102,6 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin) /// @return FAIL when writing the commands to "fd" fails. static int ses_win_rec(FILE *fd, frame_T *fr) { - frame_T *frc; int count = 0; if (fr->fr_layout == FR_LEAF) { @@ -113,7 +110,7 @@ static int ses_win_rec(FILE *fd, frame_T *fr) // Find first frame that's not skipped and then create a window for // each following one (first frame is already there). - frc = ses_skipframe(fr->fr_child); + frame_T *frc = ses_skipframe(fr->fr_child); if (frc != NULL) { while ((frc = ses_skipframe(frc->fr_next)) != NULL) { // Make window as big as possible so that we have lots of room @@ -315,14 +312,12 @@ static int ses_put_fname(FILE *fd, char *name, unsigned *flagp) /// @param current_arg_idx current argument index of the window, use -1 if unknown static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int current_arg_idx) { - win_T *save_curwin; int f; - int do_cursor; int did_next = false; // Always restore cursor position for ":mksession". For ":mkview" only // when 'viewoptions' contains "cursor". - do_cursor = (flagp == &ssop_flags || *flagp & SSOP_CURSOR); + int do_cursor = (flagp == &ssop_flags || *flagp & SSOP_CURSOR); // Local argument list. if (wp->w_alist == &global_alist) { @@ -428,7 +423,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr // used and 'sessionoptions' doesn't include "nvim/options". // Some folding options are always stored when "folds" is included, // otherwise the folds would not be restored correctly. - save_curwin = curwin; + win_T *save_curwin = curwin; curwin = wp; curbuf = curwin->w_buffer; if (*flagp & (SSOP_OPTIONS | SSOP_LOCALOPTIONS)) { @@ -534,8 +529,6 @@ static int makeopens(FILE *fd, char *dirnow) { int only_save_windows = true; int restore_size = true; - win_T *wp; - char *sname; win_T *edited_win = NULL; win_T *tab_firstwin; frame_T *tab_topframe; @@ -565,7 +558,7 @@ static int makeopens(FILE *fd, char *dirnow) if (ssop_flags & SSOP_SESDIR) { PUTLINE_FAIL("exe \"cd \" . escape(expand(\":p:h\"), ' ')"); } else if (ssop_flags & SSOP_CURDIR) { - sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow); + char *sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow); char *fname_esc = ses_escape_fname(sname, &ssop_flags); if (fprintf(fd, "cd %s\n", fname_esc) < 0) { xfree(fname_esc); @@ -691,7 +684,7 @@ static int makeopens(FILE *fd, char *dirnow) // Before creating the window layout, try loading one file. If this // is aborted we don't end up with a number of useless windows. // This may have side effects! (e.g., compressed or network file). - for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) { + for (win_T *wp = tab_firstwin; wp != NULL; wp = wp->w_next) { if (ses_do_win(wp) && wp->w_buffer->b_ffname != NULL && !bt_help(wp->w_buffer) @@ -732,7 +725,7 @@ static int makeopens(FILE *fd, char *dirnow) // Check if window sizes can be restored (no windows omitted). // Remember the window number of the current window after restoring. int nr = 0; - for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) { + for (win_T *wp = tab_firstwin; wp != NULL; wp = wp->w_next) { if (ses_do_win(wp)) { nr++; } else { @@ -781,7 +774,7 @@ static int makeopens(FILE *fd, char *dirnow) } // Restore the view of the window (options, file, cursor, etc.). - for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) { + for (win_T *wp = tab_firstwin; wp != NULL; wp = wp->w_next) { if (!ses_do_win(wp)) { continue; } -- cgit From ac1113ded5f8f09dd99a9894d7a7e795626fb728 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 13 Nov 2023 23:40:37 +0100 Subject: refactor: follow style guide - reduce variable scope - prefer initialization over declaration and assignment --- src/nvim/ex_session.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index aa85696b51..1a36014378 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -885,7 +885,6 @@ void ex_loadview(exarg_T *eap) /// - SSOP_SLASH: filenames are written with "/" slash void ex_mkrc(exarg_T *eap) { - FILE *fd; int view_session = false; // :mkview, :mksession int using_vdir = false; // using 'viewdir'? char *viewFile = NULL; @@ -925,7 +924,7 @@ void ex_mkrc(exarg_T *eap) vim_mkdir_emsg(p_vdir, 0755); } - fd = open_exfile(fname, eap->forceit, WRITEBIN); + FILE *fd = open_exfile(fname, eap->forceit, WRITEBIN); if (fd != NULL) { int failed = false; unsigned *flagp; -- cgit From 38a20dd89f91c45ec8589bf1c50d50732882d38a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 20:58:37 +0800 Subject: build(IWYU): replace most private mappings with pragmas (#26247) --- src/nvim/ex_session.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 1a36014378..903170a43c 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -29,6 +29,7 @@ #include "nvim/message.h" #include "nvim/option.h" #include "nvim/option_vars.h" +#include "nvim/os/fs.h" #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/pos.h" -- cgit From 8b428ca8b79ebb7b36c3e403ff3bcb6924a635a6 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 16:00:21 +0100 Subject: build(IWYU): fix includes for func_attr.h --- src/nvim/ex_session.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 903170a43c..f63d236b39 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -20,6 +20,7 @@ #include "nvim/file_search.h" #include "nvim/fileio.h" #include "nvim/fold.h" +#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" -- cgit From f4aedbae4cb1f206f5b7c6142697b71dd473059b Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 18:39:38 +0100 Subject: build(IWYU): fix includes for undo_defs.h --- src/nvim/ex_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index f63d236b39..faacadb5a4 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -33,7 +33,7 @@ #include "nvim/os/fs.h" #include "nvim/os/os.h" #include "nvim/path.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" #include "nvim/runtime.h" #include "nvim/vim.h" #include "nvim/window.h" -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/ex_session.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index faacadb5a4..71c01922bc 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -10,7 +10,7 @@ #include #include "nvim/arglist.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/eval.h" #include "nvim/ex_cmds_defs.h" @@ -24,7 +24,7 @@ #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mapping.h" #include "nvim/memory.h" #include "nvim/message.h" @@ -35,7 +35,7 @@ #include "nvim/path.h" #include "nvim/pos_defs.h" #include "nvim/runtime.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit