@youtyan/code-viewer 0.1.41 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/web/app.js +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youtyan/code-viewer",
3
- "version": "0.1.41",
3
+ "version": "0.1.42",
4
4
  "description": "Local browser-based code and git diff viewer",
5
5
  "type": "module",
6
6
  "bin": {
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,7 +7545,8 @@ ${frontmatter.yaml}
7544
7545
  deps.setRange(from, to);
7545
7546
  deps.syncRefInputs();
7546
7547
  deps.cancelActiveSourceLoad("navigation");
7547
- const needDiffLoad = rangeChanged || !deps.getFiles().length;
7548
+ const rangeKey = `${from}..${to}`;
7549
+ const needDiffLoad = rangeChanged || !deps.getFiles().length && emptyDiffRangeKey !== rangeKey;
7548
7550
  if (needDiffLoad) {
7549
7551
  deps.setRoute({ screen: "diff", range, path: entry.path, line });
7550
7552
  deps.setPageMode();
@@ -7552,6 +7554,7 @@ ${frontmatter.yaml}
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)) {
7557
7560
  deps.setRoute({ screen: "diff", range, path: entry.path, line }, needDiffLoad);