aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 77bed67d5f..11171617ef 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1314,7 +1314,7 @@ buflist_new (
* for hard links. */
FileID file_id;
bool file_id_valid = (sfname != NULL &&
- os_get_file_id((char *)sfname, &file_id));
+ os_fileid((char *)sfname, &file_id));
if (ffname != NULL && !(flags & BLN_DUMMY)
&& (buf = buflist_findname_file_id(ffname, &file_id,
file_id_valid)) != NULL) {
@@ -1671,7 +1671,7 @@ buf_T *buflist_findname_exp(char_u *fname)
buf_T *buflist_findname(char_u *ffname)
{
FileID file_id;
- bool file_id_valid = os_get_file_id((char *)ffname, &file_id);
+ bool file_id_valid = os_fileid((char *)ffname, &file_id);
return buflist_findname_file_id(ffname, &file_id, file_id_valid);
}
@@ -1763,13 +1763,16 @@ buflist_findpat (
if (curtab_only) {
/* Ignore the match if the buffer is not open in
* the current tab. */
- win_T *wp;
-
- for (wp = firstwin; wp != NULL; wp = wp->w_next)
- if (wp->w_buffer == buf)
+ bool found_window = false;
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_buffer == buf) {
+ found_window = true;
break;
- if (wp == NULL)
+ }
+ }
+ if (!found_window) {
continue;
+ }
}
if (match >= 0) { /* already found a match */
match = -2;
@@ -2020,22 +2023,22 @@ static void buflist_setfpos(buf_T *buf, win_T *win, linenr_T lnum, colnr_T col,
/*
- * Return TRUE when "wip" has 'diff' set and the diff is only for another tab
+ * Return true when "wip" has 'diff' set and the diff is only for another tab
* page. That's because a diff is local to a tab page.
*/
-static int wininfo_other_tab_diff(wininfo_T *wip)
+static bool wininfo_other_tab_diff(wininfo_T *wip)
{
- win_T *wp;
-
if (wip->wi_opt.wo_diff) {
- for (wp = firstwin; wp != NULL; wp = wp->w_next)
- /* return FALSE when it's a window in the current tab page, thus
+ FOR_ALL_WINDOWS(wp) {
+ /* return false when it's a window in the current tab page, thus
* the buffer was in diff mode here */
- if (wip->wi_win == wp)
- return FALSE;
- return TRUE;
+ if (wip->wi_win == wp) {
+ return false;
+ }
+ }
+ return true;
}
- return FALSE;
+ return false;
}
/*
@@ -2221,7 +2224,7 @@ setfname (
* - if the buffer is loaded, fail
* - if the buffer is not loaded, delete it from the list
*/
- file_id_valid = os_get_file_id((char *)ffname, &file_id);
+ file_id_valid = os_fileid((char *)ffname, &file_id);
if (!(buf->b_flags & BF_DUMMY)) {
obuf = buflist_findname_file_id(ffname, &file_id, file_id_valid);
}
@@ -2399,7 +2402,7 @@ static int otherfile_buf(buf_T *buf, char_u *ffname,
/* If no struct stat given, get it now */
if (file_id_p == NULL) {
file_id_p = &file_id;
- file_id_valid = os_get_file_id((char *)ffname, file_id_p);
+ file_id_valid = os_fileid((char *)ffname, file_id_p);
}
if (!file_id_valid) {
// file_id not valid, assume files are different.
@@ -2429,7 +2432,7 @@ void buf_set_file_id(buf_T *buf)
{
FileID file_id;
if (buf->b_fname != NULL
- && os_get_file_id((char *)buf->b_fname, &file_id)) {
+ && os_fileid((char *)buf->b_fname, &file_id)) {
buf->file_id_valid = true;
buf->file_id = file_id;
} else {
@@ -2441,7 +2444,7 @@ void buf_set_file_id(buf_T *buf)
static bool buf_same_file_id(buf_T *buf, FileID *file_id)
{
return buf->file_id_valid
- && os_file_id_equal(&(buf->file_id), file_id);
+ && os_fileid_equal(&(buf->file_id), file_id);
}
/*
@@ -3601,7 +3604,6 @@ do_arg_all (
)
{
int i;
- win_T *wp, *wpnext;
char_u *opened; /* Array of weight for which args are open:
* 0: not opened
* 1: opened in other tab
@@ -3651,8 +3653,9 @@ do_arg_all (
if (had_tab > 0)
goto_tabpage_tp(first_tabpage, TRUE, TRUE);
for (;; ) {
+ win_T *wpnext = NULL;
tpnext = curtab->tp_next;
- for (wp = firstwin; wp != NULL; wp = wpnext) {
+ for (win_T *wp = firstwin; wp != NULL; wp = wpnext) {
wpnext = wp->w_next;
buf = wp->w_buffer;
if (buf->b_ffname == NULL
@@ -3762,13 +3765,14 @@ do_arg_all (
if (opened[i] > 0) {
/* Move the already present window to below the current window */
if (curwin->w_arg_idx != i) {
- for (wpnext = firstwin; wpnext != NULL; wpnext = wpnext->w_next) {
- if (wpnext->w_arg_idx == i) {
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_arg_idx == i) {
if (keep_tabs) {
- new_curwin = wpnext;
+ new_curwin = wp;
new_curtab = curtab;
- } else
- win_move_after(wpnext, curwin);
+ } else {
+ win_move_after(wp, curwin);
+ }
break;
}
}
@@ -4421,8 +4425,8 @@ linenr_T buf_delsign(
}
/* When deleted the last sign needs to redraw the windows to remove the
- * sign column. */
- if (buf->b_signlist == NULL) {
+ * sign column. Not when curwin is NULL (this means we're exiting). */
+ if (buf->b_signlist != NULL && curwin != NULL) {
redraw_buf_later(buf, NOT_VALID);
changed_cline_bef_curs();
}