Fix end-of-file line feed handling
This commit is contained in:
parent
d5d04799ef
commit
0d02884572
|
@ -677,6 +677,10 @@ void add_buffer(uint8_t * buf, int size) {
|
||||||
state = 0;
|
state = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (env->lines[env->line_no-1]->actual == 0) {
|
||||||
|
/* Remove blank line from end */
|
||||||
|
remove_line(env->lines, env->line_no-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -797,6 +801,7 @@ void write_file(char * file) {
|
||||||
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
render_error("Failed to open file for writing.");
|
render_error("Failed to open file for writing.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -813,9 +818,7 @@ void write_file(char * file) {
|
||||||
fwrite(tmp, i, 1, f);
|
fwrite(tmp, i, 1, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i + 1 < env->line_count) {
|
fputc('\n', f);
|
||||||
fputc('\n', f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue