comparison src/fileio.c @ 1944:40a8e388692b v7.2.241

updated for version 7.2-241
author vimboss
date Wed, 29 Jul 2009 10:10:29 +0000
parents 3eb34a777f49
children ce6bc4bf2b87
comparison
equal deleted inserted replaced
1943:96276cc11d8e 1944:40a8e388692b
8418 { 8418 {
8419 win_alloc_aucmd_win(); 8419 win_alloc_aucmd_win();
8420 if (aucmd_win == NULL) 8420 if (aucmd_win == NULL)
8421 win = curwin; 8421 win = curwin;
8422 } 8422 }
8423 if (win == NULL && aucmd_win_used)
8424 /* Strange recursive autocommand, fall back to using the current
8425 * window. Expect a few side effects... */
8426 win = curwin;
8423 8427
8424 aco->save_curwin = curwin; 8428 aco->save_curwin = curwin;
8425 aco->save_curbuf = curbuf; 8429 aco->save_curbuf = curbuf;
8426 if (win != NULL) 8430 if (win != NULL)
8427 { 8431 {
8428 /* There is a window for "buf" in the current tab page, make it the 8432 /* There is a window for "buf" in the current tab page, make it the
8429 * curwin. This is preferred, it has the least side effects (esp. if 8433 * curwin. This is preferred, it has the least side effects (esp. if
8430 * "buf" is curbuf). */ 8434 * "buf" is curbuf). */
8435 aco->use_aucmd_win = FALSE;
8431 curwin = win; 8436 curwin = win;
8432 } 8437 }
8433 else 8438 else
8434 { 8439 {
8435 /* There is no window for "buf", use "aucmd_win". To minimize the side 8440 /* There is no window for "buf", use "aucmd_win". To minimize the side
8436 * effects, insert it in a the current tab page. 8441 * effects, insert it in a the current tab page.
8437 * Anything related to a window (e.g., setting folds) may have 8442 * Anything related to a window (e.g., setting folds) may have
8438 * unexpected results. */ 8443 * unexpected results. */
8444 aco->use_aucmd_win = TRUE;
8445 aucmd_win_used = TRUE;
8439 aucmd_win->w_buffer = buf; 8446 aucmd_win->w_buffer = buf;
8440 ++buf->b_nwindows; 8447 ++buf->b_nwindows;
8441 win_init_empty(aucmd_win); /* set cursor and topline to safe values */ 8448 win_init_empty(aucmd_win); /* set cursor and topline to safe values */
8449 vim_free(aucmd_win->w_localdir);
8450 aucmd_win->w_localdir = NULL;
8451
8452 /* Make sure w_localdir and globaldir are NULL to avoid a chdir() in
8453 * win_enter_ext(). */
8454 aucmd_win->w_localdir = NULL;
8455 aco->globaldir = globaldir;
8456 globaldir = NULL;
8457
8442 8458
8443 #ifdef FEAT_WINDOWS 8459 #ifdef FEAT_WINDOWS
8444 /* Split the current window, put the aucmd_win in the upper half. 8460 /* Split the current window, put the aucmd_win in the upper half.
8445 * We don't want the BufEnter or WinEnter autocommands. */ 8461 * We don't want the BufEnter or WinEnter autocommands. */
8446 block_autocmds(); 8462 block_autocmds();
8470 { 8486 {
8471 #ifdef FEAT_WINDOWS 8487 #ifdef FEAT_WINDOWS
8472 int dummy; 8488 int dummy;
8473 #endif 8489 #endif
8474 8490
8475 if (aco->new_curwin == aucmd_win) 8491 if (aco->use_aucmd_win)
8476 { 8492 {
8477 --curbuf->b_nwindows; 8493 --curbuf->b_nwindows;
8478 #ifdef FEAT_WINDOWS 8494 #ifdef FEAT_WINDOWS
8479 /* Find "aucmd_win", it can't be closed, but it may be in another tab 8495 /* Find "aucmd_win", it can't be closed, but it may be in another tab
8480 * page. Do not trigger autocommands here. */ 8496 * page. Do not trigger autocommands here. */
8497 } 8513 }
8498 8514
8499 /* Remove the window and frame from the tree of frames. */ 8515 /* Remove the window and frame from the tree of frames. */
8500 (void)winframe_remove(curwin, &dummy, NULL); 8516 (void)winframe_remove(curwin, &dummy, NULL);
8501 win_remove(curwin, NULL); 8517 win_remove(curwin, NULL);
8518 aucmd_win_used = FALSE;
8502 last_status(FALSE); /* may need to remove last status line */ 8519 last_status(FALSE); /* may need to remove last status line */
8503 restore_snapshot(SNAP_AUCMD_IDX, FALSE); 8520 restore_snapshot(SNAP_AUCMD_IDX, FALSE);
8504 (void)win_comp_pos(); /* recompute window positions */ 8521 (void)win_comp_pos(); /* recompute window positions */
8505 unblock_autocmds(); 8522 unblock_autocmds();
8506 8523
8515 #else 8532 #else
8516 curwin = aco->save_curwin; 8533 curwin = aco->save_curwin;
8517 #endif 8534 #endif
8518 curbuf = curwin->w_buffer; 8535 curbuf = curwin->w_buffer;
8519 8536
8537 vim_free(globaldir);
8538 globaldir = aco->globaldir;
8539
8520 /* the buffer contents may have changed */ 8540 /* the buffer contents may have changed */
8521 check_cursor(); 8541 check_cursor();
8522 if (curwin->w_topline > curbuf->b_ml.ml_line_count) 8542 if (curwin->w_topline > curbuf->b_ml.ml_line_count)
8523 { 8543 {
8524 curwin->w_topline = curbuf->b_ml.ml_line_count; 8544 curwin->w_topline = curbuf->b_ml.ml_line_count;
8539 #ifdef FEAT_WINDOWS 8559 #ifdef FEAT_WINDOWS
8540 if (win_valid(aco->save_curwin)) 8560 if (win_valid(aco->save_curwin))
8541 #endif 8561 #endif
8542 { 8562 {
8543 /* Restore the buffer which was previously edited by curwin, if 8563 /* Restore the buffer which was previously edited by curwin, if
8544 * it was chagned, we are still the same window and the buffer is 8564 * it was changed, we are still the same window and the buffer is
8545 * valid. */ 8565 * valid. */
8546 if (curwin == aco->new_curwin 8566 if (curwin == aco->new_curwin
8547 && curbuf != aco->new_curbuf 8567 && curbuf != aco->new_curbuf
8548 && buf_valid(aco->new_curbuf) 8568 && buf_valid(aco->new_curbuf)
8549 && aco->new_curbuf->b_ml.ml_mfp != NULL) 8569 && aco->new_curbuf->b_ml.ml_mfp != NULL)