mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-10 10:10:38 +08:00
Show which line is highlighted
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
mobileFileTree = false;
|
||||
|
||||
if (path) {
|
||||
project.navigateTo({ path: newPath, revision });
|
||||
project.navigateTo({ path: newPath, revision, line: null });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user