summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buffer.c6
-rw-r--r--main.c3
-rw-r--r--menu.c2
-rw-r--r--ted.h2
4 files changed, 11 insertions, 2 deletions
diff --git a/buffer.c b/buffer.c
index cc9fd80..2743a05 100644
--- a/buffer.c
+++ b/buffer.c
@@ -206,6 +206,12 @@ double buffer_last_write_time(TextBuffer *buffer) {
return buffer->last_write_time;
}
+void buffer_ignore_changes_on_disk(TextBuffer *buffer) {
+ buffer->last_write_time = timespec_to_seconds(time_last_modified(buffer->path));
+ // no matter what, buffer_unsaved_changes should return true
+ buffer->undo_history_write_pos = U32_MAX;
+}
+
BufferPos buffer_cursor_pos(TextBuffer *buffer) {
return buffer->cursor_pos;
}
diff --git a/main.c b/main.c
index f319dc6..f4a69dd 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,5 @@
/*
TODO:
-- fix ask-reload menu (clicking "no" will probably do nothing)
- public Node API
- public Selector/FileSelector API
- public Settings API
@@ -16,7 +15,7 @@ FUTURE FEATURES:
- "remove file..." menu
- auto-close brackets
- with macros we can really test performance of buffer_insert_text_at_pos, etc. (which should ideally be fast)
-- manual.md
+- manual directory
- LSP request timeout
*/
diff --git a/menu.c b/menu.c
index 1df07ea..e126fd1 100644
--- a/menu.c
+++ b/menu.c
@@ -329,6 +329,8 @@ static void ask_reload_menu_update(Ted *ted) {
break;
case POPUP_NO:
menu_close(ted);
+ if (buffer)
+ buffer_ignore_changes_on_disk(buffer);
break;
case POPUP_CANCEL: assert(0); break;
}
diff --git a/ted.h b/ted.h
index c7bb45b..79ed424 100644
--- a/ted.h
+++ b/ted.h
@@ -329,6 +329,8 @@ double buffer_get_scroll_lines(TextBuffer *buffer);
void buffer_scroll_to(TextBuffer *buffer, double cols, double lines);
/// get last time buffer was written to, in the format of \ref time_get_seconds
double buffer_last_write_time(TextBuffer *buffer);
+/// ignore any changes that have been made to the loaded file
+void buffer_ignore_changes_on_disk(TextBuffer *buffer);
/// get position of the cursor
BufferPos buffer_cursor_pos(TextBuffer *buffer);
/// returns true if anything is selected