Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Show which line is highlighted
Alexis Sellier committed 4 years ago
commit cfb695d592cc9d78b15e52bb55de0b18b00d4428
parent a41c3cd293cc45b405eee144b7060b0b83b3e8d3
3 files changed +13 -8
modified src/base/projects/Blob.svelte
@@ -7,7 +7,7 @@

  const lastCommit = blob.info.lastCommit;
  const lines = blob.binary ? 0 : (blob.content.match(/\n/g) || []).length;
-
  const lineNumbers = Array(lines).fill(0).map((_, index) => (index + 1).toString());
+
  const lineNumbers = Array(lines).fill(0).map((_, index) => index + 1);
  const parentDir = blob.path.match(/^.*\/|/)?.values().next().value;

  // Waiting onMount, due to the line numbers still loading.
@@ -66,8 +66,8 @@
  .line-number {
    display: block;
  }
-
  .line-number:hover {
-
    color: var(--color-foreground);
+
  .line-number:hover, .line-number.highlighted {
+
    color: var(--color-foreground-90);
  }

  .code {
@@ -133,7 +133,10 @@
      {:else}
        <pre class="line-numbers">
          {#each lineNumbers as lineNumber}
-
            <a href="#L{lineNumber}" class="line-number" id="L{lineNumber}">{lineNumber}</a>
+
            <a href="#L{lineNumber}"
+
               class="line-number"
+
               class:highlighted={lineNumber === line}
+
               id="L{lineNumber}">{lineNumber}</a>
          {/each}
        </pre>
        <pre
modified src/base/projects/Browser.svelte
@@ -57,7 +57,7 @@
    mobileFileTree = false;

    if (path) {
-
      project.navigateTo({ path: newPath, revision });
+
      project.navigateTo({ path: newPath, revision, line: null });
    }
  };

modified src/base/projects/ProjectRoute.svelte
@@ -15,11 +15,13 @@
  export let config: Config;
  export let hash: string | null = null;

-
  const line = formatLocationHash(hash);
-
  const browse: proj.BrowseTo = { content, peer, path: "/", line };
+
  const browse: proj.BrowseTo = { content, peer, path: "/" };
  const head = project.branches[project.defaultBranch];

-
  // route is passed when the URL has more params after e.g. /tree or /history
+
  // If line-number hash changes, we update the browser.
+
  $: browse.line = formatLocationHash(hash);
+

+
  // `route` includes any unmatched path segments.
  $: if (route) {
    const { path, revision } = proj.parseRoute(route, project.branches);