From f74a02254ac15a84d38c9a254ead293ebaad2377 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 17 Sep 2026 14:16:19 +0200 Subject: Settings changes take effect, and keep this copy respects the plan Five of the Settings window's controls - the sort order, the three column toggles and the preview height - were read when it built its new preferences but never connected to anything, so changing them did nothing until some other control happened to fire, and then they all landed at once out of nowhere. Every control is connected now. The same closure composed a whole Prefs from its own widgets, which wrote the remembered divider positions back as zeros: dragging the panes to taste and then ticking any checkbox threw them away. A settings change is now applied over the preferences as they are, by model.Prefs.WithDisplay - which is where it can be tested, and is. "Keep this copy, replace the other" wrote a Displaces straight into the chain. internal/plan refuses to build two steps that displace one path, because the second destroys what the first put there; the window went round that code, so choosing it for two duplicates of one file left both rows saying "done" with the first file in the Trash. It now refuses the second, naming the file that has the place. --- gui/internal/model/plan.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'gui/internal/model/plan.go') diff --git a/gui/internal/model/plan.go b/gui/internal/model/plan.go index c3e9654..31a783b 100644 --- a/gui/internal/model/plan.go +++ b/gui/internal/model/plan.go @@ -16,6 +16,7 @@ import ( "git.labunix.xyz/krino/internal/lock" "git.labunix.xyz/krino/internal/plan" "git.labunix.xyz/krino/internal/scan" + "git.labunix.xyz/krino/internal/xdg" ) // Row is one line of the Plan tab: a file krino would act on, or one it @@ -292,6 +293,23 @@ func (t *PlanTab) KeepThisCopy(i int) error { if row.Path == "" { return fmt.Errorf("model: %s has no path", row.Rel) } + // Only the first step to reach a path may displace it: once another + // step of this same plan is going to put its own file there, displacing + // it again would destroy that file. internal/plan refuses to build such + // a pair; the window writes its step by hand, so it must refuse too. + for _, c := range t.dp.Chains { + if c.File.Rel == row.Rel { + continue + } + for _, st := range c.Steps { + if st.Skip != "" { + continue + } + if st.Dst == row.DuplicateOf || st.Displaces == row.DuplicateOf { + return fmt.Errorf("model: %s is already spoken for by %s in this plan", xdg.Abbrev(row.DuplicateOf), c.File.Rel) + } + } + } for j, c := range t.dp.Chains { if c.File.Rel != row.Rel { continue -- cgit v1.3