Commit ab0de11d authored by Kai Willadsen's avatar Kai Willadsen
Browse files

dirdiff: Make new/deleted file comparison open in two-pane mode (#492)

The issue being addressed here is that once the comparison has been
opened, there's no clear indication of whether it was the left or the
right pane that was missing from the folder comparison.

The down-side to making us always open in two-pane mode is that we lose
the screen real estate of the single-pane view, but the benefits in
consistency feel like they outweigh that consideration. If a user really
wants a full-size view of an added/removed file without the screen
split, the Open Externally action is already available.
parent 96c2f13e
Pipeline #349639 passed with stages
in 5 minutes and 55 seconds
......@@ -1376,10 +1376,11 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
if not rows[pane]:
return
if os.path.isfile(rows[pane]):
self.create_diff_signal.emit(
[Gio.File.new_for_path(r) for r in rows if os.path.isfile(r)],
{}
)
diff_gfiles = [
Gio.File.new_for_path(r) if os.path.isfile(r) else None
for r in rows
]
self.create_diff_signal.emit(diff_gfiles, {})
elif os.path.isdir(rows[pane]):
if view.row_expanded(path):
view.collapse_row(path)
......
......@@ -122,10 +122,10 @@ def prompt_save_filename(
def find_shared_parent_path(
paths: Sequence[Gio.File],
paths: Sequence[Optional[Gio.File]],
) -> Optional[Gio.File]:
if not paths or not paths[0]:
if not paths or not paths[0] or any(path is None for path in paths):
return None
current_parent = paths[0].get_parent()
......
......@@ -22,18 +22,25 @@ from meld.iohelpers import find_shared_parent_path, format_parent_relative_path
(['/foo/a/', '/foo/b/asd/asd'], '/foo'),
# Common parent is the root
(['/foo/a/', '/bar/b/'], '/'),
# One path, one missing path
(['/foo/a', None], None),
# Two paths, one missing path
(['/foo/a', None, '/foo/c'], None),
],
)
def test_find_shared_parent_path(paths, expected_parent):
files = [Gio.File.new_for_path(p) for p in paths]
print([f.get_path() for f in files])
files = [Gio.File.new_for_path(p) if p else None for p in paths]
print([f.get_path() if f else repr(f) for f in files])
parent = find_shared_parent_path(files)
if parent is None:
assert expected_parent is None
else:
print(f'Parent: {parent.get_path()}; expected {expected_parent}')
assert parent.equal(Gio.File.new_for_path(expected_parent))
if expected_parent is None:
assert parent is None
else:
assert parent.equal(Gio.File.new_for_path(expected_parent))
@pytest.mark.parametrize(
......
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