refactor(tui): trim the folder column change to what it needs

The path splitter is a one-line stdlib call with a single caller, so it
lives beside that caller as a private fn, without its own tests. The pane
tests assert the two columns in one screen fragment each, the end-offset
test keeps only the two cases the existing name tests do not cover, and
the key-handling test that repeated one of them goes. The website mock
splits on the backslash the same way its Info pane already does.
This commit is contained in:
Michel de Graaf
2026-09-08 05:59:39 +00:00
parent da371d4176
commit 2733ee26f7
4 changed files with 22 additions and 61 deletions
+3 -11
View File
@@ -6,14 +6,6 @@ import { TuiPane } from './chrome'
import type { ResultRow, SearchRow, TransferRow, TransferStatus } from './data'
const RESULT_COLS = '30px 3fr 2fr 74px 92px 78px 74px 42px'
/** A shared path split at its last separator, as the TUI's two columns show it. */
const splitPath = (path: string): { folder: string; name: string } => {
const at = Math.max(path.lastIndexOf('\\'), path.lastIndexOf('/'))
return at < 0
? { folder: '', name: path }
: { folder: path.slice(0, at), name: path.slice(at + 1) }
}
const TRANSFER_COLS = '48px 1fr 96px 168px 74px'
interface SearchesPaneProps {
@@ -152,7 +144,7 @@ export const ResultsPane = ({
<div className="flex-1 overflow-y-auto">
{rows.map((row, i) => {
const { glyph, tone } = resultGlyph(row)
const { folder, name } = splitPath(row.name)
const parts = row.name.split('\\')
const isSelected = selected === i
return (
<button
@@ -177,10 +169,10 @@ export const ResultsPane = ({
isSelected ? 'text-[var(--color-paper)]' : 'text-[var(--color-paper-dim)]',
)}
>
{name}
{parts.at(-1)}
</span>
<span className="overflow-hidden text-ellipsis whitespace-nowrap text-[var(--color-dust)]">
{folder}
{parts.slice(0, -1).join('\\')}
</span>
<span className="text-right text-[var(--color-tape)]">{row.size}</span>
<span className="text-[var(--color-signal)]">{row.user}</span>