Skip to content

Commit d35fabf

Browse files
committed
chore: cleanup
1 parent 82f718b commit d35fabf

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

packages/app/src/components/prompt-input.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
161161
const sessionKey = createMemo(() => `${params.dir}${params.id ? "/" + params.id : ""}`)
162162
const tabs = createMemo(() => layout.tabs(sessionKey()))
163163
const view = createMemo(() => layout.view(sessionKey()))
164+
165+
const selectionPreview = (path: string, selection: FileSelection | undefined, preview: string | undefined) => {
166+
if (preview) return preview
167+
if (!selection) return undefined
168+
const content = files.get(path)?.content?.content
169+
if (!content) return undefined
170+
const start = Math.max(1, Math.min(selection.startLine, selection.endLine))
171+
const end = Math.max(selection.startLine, selection.endLine)
172+
const lines = content.split("\n").slice(start - 1, end)
173+
if (lines.length === 0) return undefined
174+
return lines.slice(0, 2).join("\n")
175+
}
176+
164177
const recent = createMemo(() => {
165178
const all = tabs().all()
166179
const active = tabs().active()

0 commit comments

Comments
 (0)