Skip to content

Commit f901908

Browse files
committed
filediff: Reset chooser filename for cancelled selection (bgo#741928)
If the user has an unsaved file and selects a new file in the chooser, we prompt for saving the existing file. If that dialog is cancelled, we're left in an inconsistent state where the file chooser thinks we've got one file, and the buffer has another. This commit adds a slightly bodgy workaround for this situation, just manually checking whether the action was cancelled. It would be possible to do something more serious by performing our checks before the chooser dialog closes, but that would be a lot more work for little gain.
1 parent 936b6ab commit f901908

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

meld/filediff.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1739,11 +1739,15 @@ def on_file_save_button_clicked(self, button):
17391739
self.save_file(idx)
17401740

17411741
def on_fileentry_file_set(self, entry):
1742+
entries = self.fileentry[:self.num_panes]
17421743
if self.check_save_modified() != Gtk.ResponseType.CANCEL:
1743-
entries = self.fileentry[:self.num_panes]
17441744
files = [e.get_file() for e in entries]
17451745
paths = [f.get_path() for f in files]
17461746
self.set_files(paths)
1747+
else:
1748+
idx = entries.index(entry)
1749+
existing_path = self.textbuffer[idx].data.filename
1750+
entry.set_filename(existing_path)
17471751
return True
17481752

17491753
def _get_focused_pane(self):

0 commit comments

Comments
 (0)