@@ -354,6 +354,25 @@ const canRestoreSelected = computed(() => isVersionRecord(selectedHistory.value?
354354const isRestoringCurrentFile = computed (() => selectedHistory .value ?.path === currentFile .value .path );
355355const getCurrentTargetPath = (row : File .FileHistoryInfo ) => row .currentPath || row .path ;
356356
357+ const syncCurrentFileContext = (history ? : File .FileHistoryInfo | null ) => {
358+ if (currentFile .value .path ) {
359+ return ;
360+ }
361+ const target = history || selectedHistory .value || historyItems .value [0 ];
362+ if (! target ) {
363+ return ;
364+ }
365+ currentFile .value = {
366+ ... currentFile .value ,
367+ path: target .currentPath || target .path || ' ' ,
368+ content: target .currentContent || currentFileContent .value || currentFile .value .content || ' ' ,
369+ extension: target .extension || currentFile .value .extension || ' ' ,
370+ language: currentFile .value .language || ' ' ,
371+ dirty: false ,
372+ scope: ' current' ,
373+ };
374+ };
375+
357376const pagination = ref ({
358377 currentPage: 1 ,
359378 pageSize: 10 ,
@@ -488,10 +507,17 @@ const loadHistoryList = async (resetPage = false) => {
488507 }
489508 historyLoading .value = true ;
490509 try {
510+ const currentScopePath =
511+ currentFile .value .path ||
512+ selectedHistory .value ?.currentPath ||
513+ selectedHistory .value ?.path ||
514+ historyItems .value [0 ]?.currentPath ||
515+ historyItems .value [0 ]?.path ||
516+ ' ' ;
491517 const res = await searchFileHistory ({
492518 page: pagination .value .currentPage ,
493519 pageSize: pagination .value .pageSize ,
494- path: scope .value === ' current' ? currentFile . value . path : ' ' ,
520+ path: scope .value === ' current' ? currentScopePath : ' ' ,
495521 scope: scope .value ,
496522 operation: operationFilter .value ,
497523 });
@@ -570,6 +596,9 @@ const deleteSelected = async (row: File.FileHistoryInfo | null) => {
570596};
571597
572598const handleScopeChange = async () => {
599+ if (scope .value === ' current' ) {
600+ syncCurrentFileContext ();
601+ }
573602 await loadHistoryList (true );
574603};
575604
@@ -633,6 +662,9 @@ const acceptParams = async (params: HistoryDrawerProps): Promise<void> => {
633662 operationFilter .value = ' ' ;
634663 scope .value = params .scope || ' current' ;
635664 drawerVisible .value = true ;
665+ if (scope .value === ' current' ) {
666+ syncCurrentFileContext ();
667+ }
636668 await loadHistorySetting ();
637669 await loadHistoryList (true );
638670};
0 commit comments