← Commit list

8f3bf4f0d

Yousong Zhou
Yousong Zhou
2017-03-24
SUCCESS Duration: 217s

Subject

vi: avoid touching a new file with ZZ when no editing has been done

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

editors/vi.c+8 -8
@@ -715,14 +715,6 @@ static int init_text_buffer(char *fn)
{
int rc;
- flush_undo_data();
- modified_count = 0;
- last_modified_count = -1;
-#if ENABLE_FEATURE_VI_YANKMARK
- /* init the marks */
- memset(mark, 0, sizeof(mark));
-#endif
-
/* allocate/reallocate text buffer */
free(text);
text_size = 10240;
@@ -737,6 +729,14 @@ static int init_text_buffer(char *fn)
// file doesnt exist. Start empty buf with dummy line
char_insert(text, '\n', NO_UNDO);
}
+
+ flush_undo_data();
+ modified_count = 0;
+ last_modified_count = -1;
+#if ENABLE_FEATURE_VI_YANKMARK
+ /* init the marks */
+ memset(mark, 0, sizeof(mark));
+#endif
return rc;
}