fix(diff): label split panes, unify the mode switch, sync split scrolling
Three things were wrong with the fresh side-by-side viewer: - The panes scrolled independently. The sync hunted the editors' templated ScrollViewers at load time, but the viewer starts collapsed (no file selected), so nothing was ever measured, no template existed, and the hook silently no-opped for the lifetime of the window. Reading now goes through TextView.ScrollOffsetChanged, which exists from construction; writing goes through a lazily resolved ScrollViewer.Offset. TextEditor.ScrollToVerticalOffset is NOT usable here - it is a silent no-op in AvaloniaEdit 12.0.0 even with the editor templated (verified headlessly). - Neither pane said what it showed. Added a BASE | WORKTREE header row inside DiffTextView, sharing the pane grid's columns so each label sits over its editor. - The layout picker was two lookalike ToggleButtons. It is now a segmented switch (Border.segmented + Button.segment.active), with wrap demoted to an icon toggle since it is orthogonal to the layout mode. The scroll sync, TextMate setup, grammar switching, brush fallback and segment struct were duplicated between this control and the 3-pane conflict resolver, which the design doc had used as a copy-paste template. They now live in DiffEditorSetup; both surfaces migrated. They stay separate controls on purpose - a read-only two-way renderer over aligned rows with filler lines is not a variant of a three-way editor over a writable document. The resolver thereby also picks up the fixed scroll sync and the TryFindResource brush lookup (its TryGetResource never resolved anything). All four merge tokens happen to equal their hardcoded fallbacks, so nothing changes on screen.
This commit is contained in:
@@ -30,10 +30,24 @@
|
||||
|
||||
<DockPanel>
|
||||
|
||||
<!-- View toolbar: layout + wrap, both persisted -->
|
||||
<!-- View toolbar: layout mode (segmented) + wrap (icon toggle), both persisted.
|
||||
Wrap is orthogonal to the layout mode, so it stays a separate control. -->
|
||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Spacing="8" Margin="16,8,16,0">
|
||||
<ToggleButton Content="{loc:Tr modals.diff.splitView}" IsChecked="{Binding IsSplitView}"/>
|
||||
<ToggleButton Content="{loc:Tr modals.diff.wrapLines}" IsChecked="{Binding WrapLines}"/>
|
||||
<Border Classes="segmented">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Classes="segment" Classes.active="{Binding !IsSplitView}"
|
||||
Content="{loc:Tr modals.diff.unifiedView}"
|
||||
Command="{Binding ShowUnifiedCommand}"/>
|
||||
<Button Classes="segment" Classes.active="{Binding IsSplitView}"
|
||||
Content="{loc:Tr modals.diff.splitView}"
|
||||
Command="{Binding ShowSplitCommand}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<ToggleButton Classes="icon-btn" IsChecked="{Binding WrapLines}"
|
||||
VerticalAlignment="Center"
|
||||
ToolTip.Tip="{loc:Tr modals.diff.wrapLines}">
|
||||
<PathIcon Data="{StaticResource Icon.Wrap}" Width="14" Height="14"/>
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Planning toolbar: combined-mode toggle + warning/loading -->
|
||||
|
||||
Reference in New Issue
Block a user