Skip to content

Commit e834b4c

Browse files
committed
File viewer: Add Ext column in Full mode
- Sortable `Ext` column between Name and Size (60px fixed width) - Shows extension without dot for files, empty for directories - Extension extraction matches Rust sorting logic (dotfiles → empty) - Selection color states for `.col-ext` follow existing pattern
1 parent 3928c1c commit e834b4c

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

apps/desktop/src/lib/file-explorer/views/FullList.svelte

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@
112112
// Measures multiple sample dates to find the maximum width needed.
113113
const dateColumnWidth = $derived(measureDateColumnWidth(formatDateTime))
114114
115+
/** Extracts display extension from a filename (no dot). Matches Rust sorting logic:
116+
* dotfiles without secondary dot → empty, no extension → empty, otherwise last segment. */
117+
function getDisplayExtension(name: string, isDirectory: boolean): string {
118+
if (isDirectory) return ''
119+
if (name.startsWith('.') && !name.slice(1).includes('.')) return ''
120+
const dotPos = name.lastIndexOf('.')
121+
if (dotPos <= 0 || dotPos === name.length - 1) return ''
122+
return name.slice(dotPos + 1)
123+
}
124+
115125
// Drive index state — show spinner while scanning OR aggregating (sizes aren't ready until aggregation finishes)
116126
const indexing = $derived(isScanning() || isAggregating())
117127
@@ -357,7 +367,7 @@
357367

358368
<div class="full-list-container" class:is-focused={isFocused} class:is-compact={isCompact}>
359369
<!-- Header row with sortable columns (outside scroll container for correct height calculation) -->
360-
<div class="header-row" style="grid-template-columns: 16px 1fr 115px {dateColumnWidth}px;">
370+
<div class="header-row" style="grid-template-columns: 16px 1fr 60px 115px {dateColumnWidth}px;">
361371
<span class="header-icon"></span>
362372
<SortableHeader
363373
column="name"
@@ -366,6 +376,13 @@
366376
currentSortOrder={sortOrder}
367377
onClick={onSortChange ?? (() => {})}
368378
/>
379+
<SortableHeader
380+
column="extension"
381+
label="Ext"
382+
currentSortColumn={sortBy}
383+
currentSortOrder={sortOrder}
384+
onClick={onSortChange ?? (() => {})}
385+
/>
369386
<SortableHeader
370387
column="size"
371388
label="Size"
@@ -405,7 +422,7 @@
405422
class:is-under-cursor={globalIndex === cursorIndex}
406423
class:is-selected={selectedIndices.has(globalIndex)}
407424
data-drop-target-path={file.isDirectory && file.name !== '..' ? file.path : undefined}
408-
style="height: {rowHeight}px; grid-template-columns: 16px 1fr 115px {dateColumnWidth}px;"
425+
style="height: {rowHeight}px; grid-template-columns: 16px 1fr 60px 115px {dateColumnWidth}px;"
409426
onmousedown={(e: MouseEvent) => {
410427
handleMouseDown(e, globalIndex)
411428
}}
@@ -438,6 +455,7 @@
438455
{:else}
439456
<span class="col-name">{file.name}</span>
440457
{/if}
458+
<span class="col-ext">{getDisplayExtension(file.name, file.isDirectory)}</span>
441459
<span
442460
class="col-size"
443461
use:tooltip={file.isDirectory
@@ -559,6 +577,14 @@
559577
white-space: nowrap;
560578
}
561579
580+
.col-ext {
581+
overflow: hidden;
582+
text-overflow: ellipsis;
583+
white-space: nowrap;
584+
font-size: var(--font-size-sm);
585+
color: var(--color-text-secondary);
586+
}
587+
562588
.col-size {
563589
text-align: right;
564590
font-size: var(--font-size-sm);
@@ -590,6 +616,10 @@
590616
color: var(--color-selection-fg);
591617
}
592618
619+
.file-entry.is-selected .col-ext {
620+
color: var(--color-selection-fg);
621+
}
622+
593623
.file-entry.is-selected .col-date {
594624
color: var(--color-selection-fg);
595625
}
@@ -624,6 +654,10 @@
624654
color: var(--color-selection-fg);
625655
}
626656
657+
.full-list-container.is-focused .file-entry.is-under-cursor.is-selected .col-ext {
658+
color: var(--color-selection-fg);
659+
}
660+
627661
.full-list-container.is-focused .file-entry.is-under-cursor.is-selected .col-date {
628662
color: var(--color-selection-fg);
629663
}

0 commit comments

Comments
 (0)