Mercurial > vim
comparison src/main.c @ 16453:4e9bea9b8025 v8.1.1231
patch 8.1.1231: asking about existing swap file unnecessarily
commit https://github.com/vim/vim/commit/67cf86bfff5fd5224d557d81cb146f46e33b831c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 28 22:25:38 2019 +0200
patch 8.1.1231: asking about existing swap file unnecessarily
Problem: Asking about existing swap file unnecessarily.
Solution: When it is safe, delete the swap file. Remove
HAS_SWAP_EXISTS_ACTION, it is always defined. (closes #1237)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 28 Apr 2019 22:30:06 +0200 |
parents | 7ae2396cef62 |
children | 5256c1e27ea6 |
comparison
equal
deleted
inserted
replaced
16452:a311ea84a94c | 16453:4e9bea9b8025 |
---|---|
48 static void edit_buffers(mparm_T *parmp, char_u *cwd); | 48 static void edit_buffers(mparm_T *parmp, char_u *cwd); |
49 static void exe_pre_commands(mparm_T *parmp); | 49 static void exe_pre_commands(mparm_T *parmp); |
50 static void exe_commands(mparm_T *parmp); | 50 static void exe_commands(mparm_T *parmp); |
51 static void source_startup_scripts(mparm_T *parmp); | 51 static void source_startup_scripts(mparm_T *parmp); |
52 static void main_start_gui(void); | 52 static void main_start_gui(void); |
53 # if defined(HAS_SWAP_EXISTS_ACTION) | |
54 static void check_swap_exists_action(void); | 53 static void check_swap_exists_action(void); |
55 # endif | |
56 # ifdef FEAT_EVAL | 54 # ifdef FEAT_EVAL |
57 static void set_progpath(char_u *argv0); | 55 static void set_progpath(char_u *argv0); |
58 # endif | 56 # endif |
59 # if defined(FEAT_CLIENTSERVER) || defined(PROTO) | 57 # if defined(FEAT_CLIENTSERVER) || defined(PROTO) |
60 static void exec_on_server(mparm_T *parmp); | 58 static void exec_on_server(mparm_T *parmp); |
782 * Need to jump to the tag before executing the '-c command'. | 780 * Need to jump to the tag before executing the '-c command'. |
783 * Makes "vim -c '/return' -t main" work. | 781 * Makes "vim -c '/return' -t main" work. |
784 */ | 782 */ |
785 if (params.tagname != NULL) | 783 if (params.tagname != NULL) |
786 { | 784 { |
787 #if defined(HAS_SWAP_EXISTS_ACTION) | |
788 swap_exists_did_quit = FALSE; | 785 swap_exists_did_quit = FALSE; |
789 #endif | |
790 | 786 |
791 vim_snprintf((char *)IObuff, IOSIZE, "ta %s", params.tagname); | 787 vim_snprintf((char *)IObuff, IOSIZE, "ta %s", params.tagname); |
792 do_cmdline_cmd(IObuff); | 788 do_cmdline_cmd(IObuff); |
793 TIME_MSG("jumping to tag"); | 789 TIME_MSG("jumping to tag"); |
794 | 790 |
795 #if defined(HAS_SWAP_EXISTS_ACTION) | |
796 /* If the user doesn't want to edit the file then we quit here. */ | 791 /* If the user doesn't want to edit the file then we quit here. */ |
797 if (swap_exists_did_quit) | 792 if (swap_exists_did_quit) |
798 getout(1); | 793 getout(1); |
799 #endif | |
800 } | 794 } |
801 | 795 |
802 /* Execute any "+", "-c" and "-S" arguments. */ | 796 /* Execute any "+", "-c" and "-S" arguments. */ |
803 if (params.n_commands > 0) | 797 if (params.n_commands > 0) |
804 exe_commands(¶ms); | 798 exe_commands(¶ms); |
2623 static void | 2617 static void |
2624 read_stdin(void) | 2618 read_stdin(void) |
2625 { | 2619 { |
2626 int i; | 2620 int i; |
2627 | 2621 |
2628 #if defined(HAS_SWAP_EXISTS_ACTION) | 2622 // When getting the ATTENTION prompt here, use a dialog |
2629 /* When getting the ATTENTION prompt here, use a dialog */ | |
2630 swap_exists_action = SEA_DIALOG; | 2623 swap_exists_action = SEA_DIALOG; |
2631 #endif | 2624 |
2632 no_wait_return = TRUE; | 2625 no_wait_return = TRUE; |
2633 i = msg_didany; | 2626 i = msg_didany; |
2634 set_buflisted(TRUE); | 2627 set_buflisted(TRUE); |
2635 (void)open_buffer(TRUE, NULL, 0); /* create memfile and read file */ | 2628 (void)open_buffer(TRUE, NULL, 0); // create memfile and read file |
2636 no_wait_return = FALSE; | 2629 no_wait_return = FALSE; |
2637 msg_didany = i; | 2630 msg_didany = i; |
2638 TIME_MSG("reading stdin"); | 2631 TIME_MSG("reading stdin"); |
2639 #if defined(HAS_SWAP_EXISTS_ACTION) | 2632 |
2640 check_swap_exists_action(); | 2633 check_swap_exists_action(); |
2641 #endif | |
2642 #if !(defined(AMIGA) || defined(MACOS_X)) | 2634 #if !(defined(AMIGA) || defined(MACOS_X)) |
2643 /* | 2635 /* |
2644 * Close stdin and dup it from stderr. Required for GPM to work | 2636 * Close stdin and dup it from stderr. Required for GPM to work |
2645 * properly, and for running external commands. | 2637 * properly, and for running external commands. |
2646 * Is there any other system that cannot do this? | 2638 * Is there any other system that cannot do this? |
2739 #ifdef FEAT_FOLDING | 2731 #ifdef FEAT_FOLDING |
2740 /* Set 'foldlevel' to 'foldlevelstart' if it's not negative. */ | 2732 /* Set 'foldlevel' to 'foldlevelstart' if it's not negative. */ |
2741 if (p_fdls >= 0) | 2733 if (p_fdls >= 0) |
2742 curwin->w_p_fdl = p_fdls; | 2734 curwin->w_p_fdl = p_fdls; |
2743 #endif | 2735 #endif |
2744 #if defined(HAS_SWAP_EXISTS_ACTION) | 2736 // When getting the ATTENTION prompt here, use a dialog |
2745 /* When getting the ATTENTION prompt here, use a dialog */ | |
2746 swap_exists_action = SEA_DIALOG; | 2737 swap_exists_action = SEA_DIALOG; |
2747 #endif | 2738 |
2748 set_buflisted(TRUE); | 2739 set_buflisted(TRUE); |
2749 | 2740 |
2750 /* create memfile, read file */ | 2741 /* create memfile, read file */ |
2751 (void)open_buffer(FALSE, NULL, 0); | 2742 (void)open_buffer(FALSE, NULL, 0); |
2752 | 2743 |
2753 #if defined(HAS_SWAP_EXISTS_ACTION) | |
2754 if (swap_exists_action == SEA_QUIT) | 2744 if (swap_exists_action == SEA_QUIT) |
2755 { | 2745 { |
2756 if (got_int || only_one_window()) | 2746 if (got_int || only_one_window()) |
2757 { | 2747 { |
2758 /* abort selected or quit and only one window */ | 2748 /* abort selected or quit and only one window */ |
2766 curwin->w_arg_idx = -1; | 2756 curwin->w_arg_idx = -1; |
2767 swap_exists_action = SEA_NONE; | 2757 swap_exists_action = SEA_NONE; |
2768 } | 2758 } |
2769 else | 2759 else |
2770 handle_swap_exists(NULL); | 2760 handle_swap_exists(NULL); |
2771 #endif | |
2772 dorewind = TRUE; /* start again */ | 2761 dorewind = TRUE; /* start again */ |
2773 } | 2762 } |
2774 ui_breakcheck(); | 2763 ui_breakcheck(); |
2775 if (got_int) | 2764 if (got_int) |
2776 { | 2765 { |
2863 if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL) | 2852 if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL) |
2864 { | 2853 { |
2865 curwin->w_arg_idx = arg_idx; | 2854 curwin->w_arg_idx = arg_idx; |
2866 /* Edit file from arg list, if there is one. When "Quit" selected | 2855 /* Edit file from arg list, if there is one. When "Quit" selected |
2867 * at the ATTENTION prompt close the window. */ | 2856 * at the ATTENTION prompt close the window. */ |
2868 # ifdef HAS_SWAP_EXISTS_ACTION | |
2869 swap_exists_did_quit = FALSE; | 2857 swap_exists_did_quit = FALSE; |
2870 # endif | |
2871 (void)do_ecmd(0, arg_idx < GARGCOUNT | 2858 (void)do_ecmd(0, arg_idx < GARGCOUNT |
2872 ? alist_name(&GARGLIST[arg_idx]) : NULL, | 2859 ? alist_name(&GARGLIST[arg_idx]) : NULL, |
2873 NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin); | 2860 NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin); |
2874 # ifdef HAS_SWAP_EXISTS_ACTION | |
2875 if (swap_exists_did_quit) | 2861 if (swap_exists_did_quit) |
2876 { | 2862 { |
2877 /* abort or quit selected */ | 2863 /* abort or quit selected */ |
2878 if (got_int || only_one_window()) | 2864 if (got_int || only_one_window()) |
2879 { | 2865 { |
2882 getout(1); | 2868 getout(1); |
2883 } | 2869 } |
2884 win_close(curwin, TRUE); | 2870 win_close(curwin, TRUE); |
2885 advance = FALSE; | 2871 advance = FALSE; |
2886 } | 2872 } |
2887 # endif | |
2888 if (arg_idx == GARGCOUNT - 1) | 2873 if (arg_idx == GARGCOUNT - 1) |
2889 arg_had_last = TRUE; | 2874 arg_had_last = TRUE; |
2890 ++arg_idx; | 2875 ++arg_idx; |
2891 } | 2876 } |
2892 ui_breakcheck(); | 2877 ui_breakcheck(); |
3483 else | 3468 else |
3484 #endif | 3469 #endif |
3485 mch_exit(0); | 3470 mch_exit(0); |
3486 } | 3471 } |
3487 | 3472 |
3488 #if defined(HAS_SWAP_EXISTS_ACTION) | |
3489 /* | 3473 /* |
3490 * Check the result of the ATTENTION dialog: | 3474 * Check the result of the ATTENTION dialog: |
3491 * When "Quit" selected, exit Vim. | 3475 * When "Quit" selected, exit Vim. |
3492 * When "Recover" selected, recover the file. | 3476 * When "Recover" selected, recover the file. |
3493 */ | 3477 */ |
3496 { | 3480 { |
3497 if (swap_exists_action == SEA_QUIT) | 3481 if (swap_exists_action == SEA_QUIT) |
3498 getout(1); | 3482 getout(1); |
3499 handle_swap_exists(NULL); | 3483 handle_swap_exists(NULL); |
3500 } | 3484 } |
3501 #endif | |
3502 | 3485 |
3503 #endif /* NO_VIM_MAIN */ | 3486 #endif /* NO_VIM_MAIN */ |
3504 | 3487 |
3505 #if defined(STARTUPTIME) || defined(PROTO) | 3488 #if defined(STARTUPTIME) || defined(PROTO) |
3506 static struct timeval prev_timeval; | 3489 static struct timeval prev_timeval; |