Skip to content

Commit

Permalink
Ensure that file is flushed and synced when saving in kilo.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbtronics committed Oct 21, 2022
1 parent 80c2c3e commit ee7a92e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/kilo/kilo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,12 @@ namespace ESP32Console::Kilo
close(fd);*/
free(buf);

//Ensure that the file is really written to FS before closing it
fflush(file);
fsync(fileno(file));
fclose(file);

E.dirty = 0;
editorSetStatusMessage("%d bytes written on disk", len);
return 0;
Expand Down

0 comments on commit ee7a92e

Please sign in to comment.