Commit 37a8908c authored by Kai Willadsen's avatar Kai Willadsen

filediff: Make unsaved change warning specific to reloaded files (#161)

Our "do you want to discard changes?" confirmation was written for the
revert-to-saved case, which reverts all panes at once. We're now reusing
it for the reload caused by encoding change, but it's still warning if
any file has been modified, even though it only reloads one file.

This change makes it so that the unsaved changes check takes a list of
panes that are being reloaded, and uses that in the encoding handler.
parent 80fb5d35
......@@ -236,9 +236,10 @@ class FileDiff(MeldDoc, Component):
def reload_with_encoding(widget, encoding, pane):
if not self.check_unsaved_changes():
buffer = self.textbuffer[pane]
if not self.check_unsaved_changes([buffer]):
self.set_file(pane, self.textbuffer[pane].data.gfile, encoding)
self.set_file(pane,, encoding)
def go_to_line(widget, line, pane):
self.move_cursor(pane, line, focus=False)
......@@ -1704,8 +1705,9 @@ class FileDiff(MeldDoc, Component):
return i
return -1
def check_unsaved_changes(self):
unsaved = [ for b in self.textbuffer if b.get_modified()]
def check_unsaved_changes(self, buffers=None):
buffers = buffers or self.textbuffer
unsaved = [ for b in buffers if b.get_modified()]
if not unsaved:
return True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment