Skip to content

Commit 496100f

Browse files
fix(diff-view): restore scroll position and fix tab handling on save/deny (#589)
* fix(diff-view): restore scroll position and fix tab handling on save/deny * fix(diff-view): restore preview tabs to their original editor group * feat: keep diff target tab open on user interaction, mirror scroll position * feat(settings): expose auto-close diff-view tab settings in UI tab - Add autoCloseZooOpenedFiles, autoCloseZooOpenedFilesAfterUserEdited, and autoCloseZooOpenedNewFiles to global settings schema - Render checkboxes for all three in UISettings component - Wire through SettingsView cachedState - Add i18n keys under ui namespace in all 18 locales - Add UISettings.spec.tsx tests for the new checkboxes - Add changeset * fix(diff-view): fix CI under vitest v4 and address review feedback CI fixes (DiffViewProvider.spec.ts): - check-types: cast partial task mock to satisfy Task param (TS2345) - platform-unit-test: convert Range/Position/Selection arrow mocks to regular functions so they are constructable under vitest v4 (v4 invokes mockImplementation as a constructor for `new`) Review feedback: - reset(): dispose listeners + cancelDeferredScroll before closeAllDiffViews - add regression test: revertChanges ignores userTouchedDiffEditor (deny) - replace scrollCallback non-null assertion with a defensive guard - reword changeset preview-tab sentence - restore proper diacritics/Cyrillic in de/fr/it/ru/vi auto-close settings --------- Co-authored-by: Naved Merchant <naved.merchant@gmail.com>
1 parent 4bd0645 commit 496100f

28 files changed

Lines changed: 2195 additions & 22 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"zoo-code": minor
3+
---
4+
5+
Add settings to control whether editor tabs Zoo opens during diff edits are auto-closed after accept/reject: auto-close transiently-opened files, auto-close even after user interaction (a refinement of the first), and auto-close newly created files.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"zoo-code": patch
3+
---
4+
5+
Fix diff view scroll position and tab handling when applying edits. The diff now opens scrolled to the first changed line (including end-of-file removals, which are clamped to a valid line in the modified document) instead of forcing the viewport to the top. After accepting or rejecting a diff, files that were already open are restored to their pre-edit scroll position, and files that were not open before the edit have their transiently opened tab closed -- unless the user activated that tab during the diff, in which case it is kept open. Focus is no longer pulled back to the edited file when the user has navigated elsewhere. A file that was open in a preview tab is restored in a preview tab with the original scroll position, even if the target file replaced the preview tab and was automatically closed after the diff was accepted or rejected. A file that was pinned before the edit is re-pinned after the diff closes, so applying a diff no longer drops the tab's pinned state.
6+
7+
When a user clicks or edits inside the diff pane, the target file's tab is kept open after saving -- even if it was not previously open. If the user only scrolls in the diff pane, the existing close behavior is preserved. When the target file is re-revealed after a diff, it scrolls to the position most recently viewed by the user: if the user last scrolled in the diff pane, the target file mirrors that scroll position; if the user last scrolled in the target file's own editor, that position is used instead; otherwise the pre-edit scroll position is restored.

packages/types/src/global-settings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ export const globalSettingsSchema = z.object({
180180
execaShellPath: z.string().optional(),
181181

182182
diagnosticsEnabled: z.boolean().optional(),
183+
autoCloseZooOpenedFiles: z.boolean().optional(),
184+
autoCloseZooOpenedFilesAfterUserEdited: z.boolean().optional(),
185+
autoCloseZooOpenedNewFiles: z.boolean().optional(),
183186

184187
rateLimitSeconds: z.number().optional(),
185188
experiments: experimentsSchema.optional(),

packages/types/src/vscode-extension-host.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ export type ExtensionState = Pick<
282282
| "terminalProfile"
283283
| "execaShellPath"
284284
| "diagnosticsEnabled"
285+
| "autoCloseZooOpenedFiles"
286+
| "autoCloseZooOpenedFilesAfterUserEdited"
287+
| "autoCloseZooOpenedNewFiles"
285288
| "language"
286289
| "modeApiConfigs"
287290
| "customModePrompts"

src/integrations/editor/DiffViewProvider.ts

Lines changed: 506 additions & 19 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)