@youtyan/code-viewer 0.1.40 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/web/app.js +17 -5
package/package.json
CHANGED
package/web/app.js
CHANGED
|
@@ -7016,6 +7016,7 @@ ${frontmatter.yaml}
|
|
|
7016
7016
|
cb();
|
|
7017
7017
|
}
|
|
7018
7018
|
const annotationOpenedCallbacks = [];
|
|
7019
|
+
let emptyDiffRangeKey = null;
|
|
7019
7020
|
function notifyAnnotationOpened(entryId) {
|
|
7020
7021
|
for (const cb of annotationOpenedCallbacks)
|
|
7021
7022
|
cb(entryId);
|
|
@@ -7544,16 +7545,27 @@ ${frontmatter.yaml}
|
|
|
7544
7545
|
deps.setRange(from, to);
|
|
7545
7546
|
deps.syncRefInputs();
|
|
7546
7547
|
deps.cancelActiveSourceLoad("navigation");
|
|
7547
|
-
|
|
7548
|
-
deps.
|
|
7549
|
-
|
|
7550
|
-
|
|
7548
|
+
const rangeKey = `${from}..${to}`;
|
|
7549
|
+
const needDiffLoad = rangeChanged || !deps.getFiles().length && emptyDiffRangeKey !== rangeKey;
|
|
7550
|
+
if (needDiffLoad) {
|
|
7551
|
+
deps.setRoute({ screen: "diff", range, path: entry.path, line });
|
|
7552
|
+
deps.setPageMode();
|
|
7551
7553
|
deps.removeStandaloneSource();
|
|
7552
7554
|
await deps.load();
|
|
7553
7555
|
if (stale())
|
|
7554
7556
|
return;
|
|
7557
|
+
emptyDiffRangeKey = deps.getFiles().length ? null : rangeKey;
|
|
7555
7558
|
}
|
|
7556
7559
|
if (deps.getFiles().some((f2) => f2.path === entry.path)) {
|
|
7560
|
+
deps.setRoute({ screen: "diff", range, path: entry.path, line }, needDiffLoad);
|
|
7561
|
+
deps.setPageMode();
|
|
7562
|
+
const hasDiffCards = !!document.querySelector(".gdp-file-shell:not(.gdp-standalone-source)");
|
|
7563
|
+
if (!hasDiffCards) {
|
|
7564
|
+
deps.removeStandaloneSource();
|
|
7565
|
+
await deps.load();
|
|
7566
|
+
if (stale())
|
|
7567
|
+
return;
|
|
7568
|
+
}
|
|
7557
7569
|
deps.removeStandaloneSource();
|
|
7558
7570
|
deps.scrollToFile(entry.path, line);
|
|
7559
7571
|
await expandAnnotationContext(entry);
|
|
@@ -7563,7 +7575,7 @@ ${frontmatter.yaml}
|
|
|
7563
7575
|
const ref = annotationRefForEntry(entry);
|
|
7564
7576
|
const card = document.querySelector(".gdp-standalone-source");
|
|
7565
7577
|
const reusable = prevRoute.screen === "file" && prevRoute.path === entry.path && prevRoute.ref === ref && card?.dataset.path === entry.path && !!card.querySelector(".gdp-source-table");
|
|
7566
|
-
deps.setRoute({ screen: "file", path: entry.path, ref, view: "blob", line, range },
|
|
7578
|
+
deps.setRoute({ screen: "file", path: entry.path, ref, view: "blob", line, range }, needDiffLoad);
|
|
7567
7579
|
deps.setPageMode();
|
|
7568
7580
|
if (reusable && card) {
|
|
7569
7581
|
focusStandaloneSourceLines(card, entry);
|