1616
1717<script setup lang="ts">
1818import { useWindowSize } from " @vueuse/core" ;
19- import { computed , onUnmounted , ref , useTemplateRef , watch , watchEffect } from " vue" ;
19+ import { computed , onUnmounted , ref , useTemplateRef , watch } from " vue" ;
2020import { useCommandRegistry , useContextKeys } from " ../../shared/command" ;
2121import { useRepoStore } from " ../../shared/repo" ;
2222import { GitGraphPane } from " ../git-graph" ;
@@ -124,12 +124,16 @@ const maxPreviewWidth = computed(() => {
124124 );
125125});
126126
127- // ウィンドウ縮小時に Preview 幅をクランプ
128- watchEffect (() => {
129- if (previewWidth .value > maxPreviewWidth .value ) {
130- previewWidth .value = Math .max (PREVIEW_MIN_WIDTH , maxPreviewWidth .value );
131- }
132- });
127+ // ウィンドウ縮小時に Preview 幅をクランプ。書き換え対象 previewWidth は source に含めない
128+ watch (
129+ maxPreviewWidth ,
130+ (maxW ) => {
131+ if (previewWidth .value > maxW ) {
132+ previewWidth .value = Math .max (PREVIEW_MIN_WIDTH , maxW );
133+ }
134+ },
135+ { immediate: true },
136+ );
133137
134138/** ドラッグ開始時に popover 左側の空きスペースを返す(Navigator + 開閉ボタン分を除く) */
135139const getPreviewBeforeSize = () =>
@@ -140,9 +144,13 @@ const getPreviewAfterSize = () =>
140144 previewPopoverRef .value ?.getBoundingClientRect ().width ?? previewWidth .value ;
141145
142146// previewVisible context key を実際の表示状態と同期
143- watchEffect (() => {
144- contextKeys .set (" previewVisible" , previewOpen .value );
145- });
147+ watch (
148+ previewOpen ,
149+ (open ) => {
150+ contextKeys .set (" previewVisible" , open );
151+ },
152+ { immediate: true },
153+ );
146154
147155/** :popover-open でガードして二重呼び出し例外を防止 */
148156function openPreview() {
@@ -185,13 +193,18 @@ function getCenterTerminalHeight(): number {
185193 return centerTerminalRef .value ?.offsetHeight ?? TERMINAL_MIN_HEIGHT ;
186194}
187195
188- // ウィンドウ縦縮小時に gitGraphHeight をクランプ(Terminal が潰れるのを防ぐ)
189- watchEffect (() => {
190- const maxGitGraph = windowHeight .value - TERMINAL_MIN_HEIGHT - HANDLE_WIDTH ;
191- if (gitGraphHeight .value > maxGitGraph ) {
192- gitGraphHeight .value = Math .max (GIT_GRAPH_MIN_HEIGHT , maxGitGraph );
193- }
194- });
196+ // ウィンドウ縦縮小時に gitGraphHeight をクランプ(Terminal が潰れるのを防ぐ)。
197+ // 書き換え対象 gitGraphHeight は source に含めない
198+ watch (
199+ windowHeight ,
200+ (h ) => {
201+ const maxGitGraph = h - TERMINAL_MIN_HEIGHT - HANDLE_WIDTH ;
202+ if (gitGraphHeight .value > maxGitGraph ) {
203+ gitGraphHeight .value = Math .max (GIT_GRAPH_MIN_HEIGHT , maxGitGraph );
204+ }
205+ },
206+ { immediate: true },
207+ );
195208 </script >
196209
197210<template >
0 commit comments