mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
codespan link
This commit is contained in:
parent
a3cfd0d023
commit
39e989d3cc
2 changed files with 17 additions and 4 deletions
|
|
@ -910,28 +910,40 @@ class ChatThreadService extends Disposable implements IChatThreadService {
|
|||
|
||||
const doesUriMatchTarget = (uri: URI) => uri.path.includes(target)
|
||||
|
||||
// check if any prevFiles are the `codespanSearch`
|
||||
// check if any prevFiles are the `target`
|
||||
for (const [idx, uri] of prevUris.entries()) {
|
||||
if (doesUriMatchTarget(uri)) {
|
||||
|
||||
// shorten it
|
||||
|
||||
// TODO make this logic more general
|
||||
const prevUriStrs = prevUris.map(uri => uri.toString())
|
||||
const shortenedUriStrs = shorten(prevUriStrs)
|
||||
const displayText = shortenedUriStrs[idx]
|
||||
let displayText = shortenedUriStrs[idx]
|
||||
const ellipsisIdx = displayText.lastIndexOf('…/');
|
||||
if (ellipsisIdx >= 0) {
|
||||
displayText = displayText.slice(ellipsisIdx + 2)
|
||||
}
|
||||
|
||||
return { uri, displayText }
|
||||
}
|
||||
}
|
||||
|
||||
// else search codebase for file
|
||||
// else search codebase for `target`
|
||||
const { uris } = await this._toolsService.callTool['pathname_search']({ queryStr: target, pageNumber: 0 })
|
||||
|
||||
for (const [idx, uri] of uris.entries()) {
|
||||
if (doesUriMatchTarget(uri)) {
|
||||
|
||||
// TODO make this logic more general
|
||||
const prevUriStrs = prevUris.map(uri => uri.toString())
|
||||
const shortenedUriStrs = shorten(prevUriStrs)
|
||||
const displayText = shortenedUriStrs[idx]
|
||||
let displayText = shortenedUriStrs[idx]
|
||||
const ellipsisIdx = displayText.lastIndexOf('…/');
|
||||
if (ellipsisIdx >= 0) {
|
||||
displayText = displayText.slice(ellipsisIdx + 2)
|
||||
}
|
||||
|
||||
|
||||
return { uri, displayText }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ const CodespanWithLink = ({ text, rawText, chatMessageLocation }: { text: string
|
|||
}
|
||||
|
||||
return <Codespan
|
||||
// text={link?.displayText || text}
|
||||
text={link?.displayText || text}
|
||||
onClick={onClick}
|
||||
className={link ? 'underline hover:brightness-90 transition-all duration-200 cursor-pointer' : ''}
|
||||
|
|
|
|||
Loading…
Reference in a new issue