micro/internal/buffer
rfjakob 1b4f6ecb12
save: fsync data safely to disk (#2681)
On modern Linux systems, it can take 30 seconds for
the data to actually hit the disk (check
/proc/sys/vm/dirty_expire_centisecs).

If the computer crashes in those 30 seconds, the user
may end up with an empty file as seen here:
https://github.com/neovim/neovim/issues/9888

This is why editors like vim and nano call
the fsync syscall after they wrote the file.
This syscall is available as file.Sync() in Go.

Running strace against micro shows that fsync is
called as expected:

	$ strace -f -p $(pgrep micro) -e fsync
	strace: Process 3284344 attached with 9 threads
	[pid 3284351] fsync(8)                  = 0

Also, we now catch errors returned from w.Flush().
2023-05-25 22:21:19 -07:00
..
autocomplete.go Fix buffer.RuneAt (#1895) 2020-10-19 20:36:14 -04:00
backup.go Allow aborting while opening a file with backup 2021-08-02 21:05:22 -04:00
buffer.go Goto next/previous diff commands + minor cleanups (#2759) 2023-04-20 15:23:35 -07:00
buffer_generated_test.go Merge branch 'buffer-benchmarks' of https://github.com/p-e-w/micro into p-e-w-buffer-benchmarks 2020-05-20 15:28:36 -04:00
buffer_test.go Use CharacterCount over RuneCount 2020-05-20 16:47:08 -04:00
cursor.go Implement moving cursor up/down within a wrapped line 2021-04-08 23:54:02 +02:00
eventhandler.go Use CharacterCount over RuneCount 2020-05-20 16:47:08 -04:00
line_array.go Support for highlighting all search matches (hlsearch) (#1762) 2021-09-28 13:39:03 -07:00
line_array_test.go Improve unicode line array test 2020-05-20 19:53:54 -04:00
loc.go Use CharacterCount over RuneCount 2020-05-20 16:47:08 -04:00
message.go Warn for readonly instead of setting option 2021-05-19 14:58:00 -04:00
save.go save: fsync data safely to disk (#2681) 2023-05-25 22:21:19 -07:00
search.go Improve comments 2021-08-21 17:58:30 -04:00
serialize.go Fix quality issues (#1856) 2020-09-16 00:08:01 -04:00
settings.go Reload settings when filetype is changed 2023-01-26 18:21:35 -08:00
stack.go Change project layout and use go.mod 2019-12-25 17:05:10 -05:00
stack_test.go Change project layout and use go.mod 2019-12-25 17:05:10 -05:00