aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2017-03-24 21:13:10 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2017-03-24 21:13:10 +0100
commit8f3bf4f0d3605b50a8e4c48c89aeabc455f04884 (patch)
tree2d0dbeef548eacb8880414da450f067741de87d0
parente3b65ab43d2e2d097a4cd2ee5aa1e1606a8a0663 (diff)
downloadbusybox-w32-8f3bf4f0d3605b50a8e4c48c89aeabc455f04884.tar.gz
busybox-w32-8f3bf4f0d3605b50a8e4c48c89aeabc455f04884.tar.bz2
busybox-w32-8f3bf4f0d3605b50a8e4c48c89aeabc455f04884.zip
vi: avoid touching a new file with ZZ when no editing has been done
This is the behaviour observed with standard vim and busybox vi of at least 1.22.1. It was changed with commit "32afd3a vi: some simplifications" which happened before 1.23.0. Mistyping filename on command line happens fairly often and it's better we restore the old behaviour to avoid a few unnecessary flash writes and sometimes efforts of debugging bugs caused by those unneeded stray files. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/vi.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 1e39b52ff..f33db66c6 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -715,14 +715,6 @@ static int init_text_buffer(char *fn)
715{ 715{
716 int rc; 716 int rc;
717 717
718 flush_undo_data();
719 modified_count = 0;
720 last_modified_count = -1;
721#if ENABLE_FEATURE_VI_YANKMARK
722 /* init the marks */
723 memset(mark, 0, sizeof(mark));
724#endif
725
726 /* allocate/reallocate text buffer */ 718 /* allocate/reallocate text buffer */
727 free(text); 719 free(text);
728 text_size = 10240; 720 text_size = 10240;
@@ -737,6 +729,14 @@ static int init_text_buffer(char *fn)
737 // file doesnt exist. Start empty buf with dummy line 729 // file doesnt exist. Start empty buf with dummy line
738 char_insert(text, '\n', NO_UNDO); 730 char_insert(text, '\n', NO_UNDO);
739 } 731 }
732
733 flush_undo_data();
734 modified_count = 0;
735 last_modified_count = -1;
736#if ENABLE_FEATURE_VI_YANKMARK
737 /* init the marks */
738 memset(mark, 0, sizeof(mark));
739#endif
740 return rc; 740 return rc;
741} 741}
742 742