0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-12-09 20:04:33 +01:00

Fix unfold when loading with line selections

This commit is contained in:
Lunny Xiao 2025-11-23 17:12:06 -08:00
parent c144b64e82
commit 373b530a8c
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

View File

@ -8,7 +8,7 @@ import {showErrorToast} from '../modules/toast.ts';
import {submitEventSubmitter, queryElemSiblings, hideElem, showElem, animateOnce, addDelegatedEventListener, createElementFromHTML, queryElems} from '../utils/dom.ts';
import {POST, GET} from '../modules/fetch.ts';
import {createTippy} from '../modules/tippy.ts';
import {invertFileFolding} from './file-fold.ts';
import {invertFileFolding, setFileFolding} from './file-fold.ts';
import {parseDom, sleep} from '../utils.ts';
import {registerGlobalSelectorFunc} from '../modules/observer.ts';
@ -127,11 +127,11 @@ async function highlightDiffSelectionFromHash(): Promise<boolean> {
if (!container) return false;
// Check if the file is collapsed and expand it if needed
const fileContent = container.querySelector<HTMLElement>('.file-content');
if (fileContent?.classList.contains('folded')) {
if (container.getAttribute('data-folded') === 'true') {
const foldBtn = container.querySelector<HTMLElement>('.fold-file');
if (foldBtn) {
invertFileFolding(fileContent, foldBtn);
// Expand the file using the setFileFolding utility
setFileFolding(container, foldBtn, false);
// Wait a bit for the expansion animation
await sleep(100);
}