File tree Expand file tree Collapse file tree
packages/app/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( )
You can’t perform that action at this time.
0 commit comments