Fixed paste next _again_ fixed the really horrible nonsense with ! marked files

master
Allen Webster 2019-10-07 18:08:42 -07:00
parent 41b6705e84
commit 54c5ce389b
5 changed files with 25 additions and 16 deletions

View File

@ -528,7 +528,7 @@ create_file(Models *models, String_Const_u8 file_name, Buffer_Create_Flag flags)
}
if (file != 0 && HasFlag(flags, BufferCreate_JustChangedFile)){
file->state.ignore_behind_os = 1;
file->state.save_state = FileSaveState_SavedWaitingForNotification;
}
if (file != 0 && HasFlag(flags, BufferCreate_AlwaysNew)){

View File

@ -168,16 +168,13 @@ save_file_to_name(Models *models, Editing_File *file, u8 *file_name){
String_Const_u8 saveable_string = buffer_stringify(scratch, buffer, Ii64(0, buffer_size(buffer)));
File_Attributes new_attributes = system_save_file(scratch, (char*)file_name, saveable_string);
if (new_attributes.last_write_time > 0){
if (using_actual_file_name){
file->state.ignore_behind_os = 1;
}
file->attributes = new_attributes;
if (new_attributes.last_write_time > 0 &&
using_actual_file_name){
file->state.save_state = FileSaveState_SavedWaitingForNotification;
file_clear_dirty_flags(file);
}
LogEventF(log_string(M), scratch, file->id, 0, system_thread_get_id(),
"save file [last_write_time=0x%llx]", new_attributes.last_write_time);
file_clear_dirty_flags(file);
}
return(result);

View File

@ -50,6 +50,12 @@ struct Line_Layout_Key{
i64 line_number;
};
typedef i32 File_Save_State;
enum{
FileSaveState_Normal,
FileSaveState_SavedWaitingForNotification,
};
struct Editing_File_State{
Gap_Buffer buffer;
@ -59,7 +65,7 @@ struct Editing_File_State{
Text_Effect paste_effect;
Dirty_State dirty;
u32 ignore_behind_os;
File_Save_State save_state;
File_Edit_Positions edit_pos_most_recent;
File_Edit_Positions edit_pos_stack[16];

View File

@ -22,6 +22,11 @@ file_change_notification_check(Arena *scratch, Working_Set *working_set, Editing
String_Const_u8 name = SCu8(file->canon.name_space, file->canon.name_size);
File_Attributes attributes = system_quick_file_attributes(scratch, name);
if (attributes.last_write_time > file->attributes.last_write_time){
if (file->state.save_state == FileSaveState_SavedWaitingForNotification){
file->state.save_state = FileSaveState_Normal;
file->attributes = attributes;
}
else{
file_add_dirty_flag(file, DirtyState_UnloadedChanges);
if (file->external_mod_node.next == 0){
LogEventF(log_string(M), &working_set->arena, file->id, 0, system_thread_get_id(),
@ -30,6 +35,7 @@ file_change_notification_check(Arena *scratch, Working_Set *working_set, Editing
system_signal_step(0);
}
}
}
file->attributes = attributes;
}
}

View File

@ -81,7 +81,7 @@ CUSTOM_DOC("If the previous command was paste or paste_next, replaces the paste
Managed_Scope scope = view_get_managed_scope(app, view);
no_mark_snap_to_cursor(app, scope);
Rewrite_Type *rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type);
Rewrite_Type *rewrite = scope_attachment(app, scope, view_rewrite_loc, Rewrite_Type);
if (*rewrite == Rewrite_Paste){
Rewrite_Type *next_rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type);
*next_rewrite = Rewrite_Paste;