fix: always call reload_file when re-openning an hidden non-ephemeral buffer
This is less confusing than just restoring the buffer as is. If the file has changed on disk the usual expectation is to load the new contents on re-opening the file. closes #339
This commit is contained in:
		
							parent
							
								
									45669cad31
								
							
						
					
					
						commit
						02deaab3a7
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		|  | @ -41,7 +41,11 @@ pub fn delete_buffer(self: *Self, buffer_: *Buffer) void { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn open_file(self: *Self, file_path: []const u8) Buffer.LoadFromFileError!*Buffer { | pub fn open_file(self: *Self, file_path: []const u8) Buffer.LoadFromFileError!*Buffer { | ||||||
|     const buffer = if (self.get_buffer(file_path)) |buffer| buffer else blk: { |     const buffer = if (self.get_buffer(file_path)) |buffer| blk: { | ||||||
|  |         if (!buffer.ephemeral and buffer.hidden) | ||||||
|  |             try buffer.refresh_from_file(); | ||||||
|  |         break :blk buffer; | ||||||
|  |     } else blk: { | ||||||
|         var buffer = try Buffer.create(self.allocator); |         var buffer = try Buffer.create(self.allocator); | ||||||
|         errdefer buffer.deinit(); |         errdefer buffer.deinit(); | ||||||
|         try buffer.load_from_file_and_update(file_path); |         try buffer.load_from_file_and_update(file_path); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue