Skip to content

Commit

Permalink
Merge pull request #3624 from continuedev/dallin/greedy-backticks
Browse files Browse the repository at this point in the history
FilenameLink: match exact basename
  • Loading branch information
sestinj authored Jan 7, 2025
2 parents a0d0bda + c97c88f commit fcc4c99
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions gui/src/components/markdown/StyledMarkdownPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,22 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
code: ({ ...codeProps }) => {
const content = getCodeChildrenContent(codeProps.children);

if (content && previousFileContextItemsRef.current) {
if (content) {
// Insert file links for matching previous context items
const ctxItem = previousFileContextItemsRef.current.find((item) =>
item.uri!.value!.includes(content),
);
if (ctxItem) {
const rif = ctxItemToRifWithContents(ctxItem);
return <FilenameLink rif={rif} />;
// With some reasonable limitations on what might be a filename
if (
previousFileContextItemsRef.current?.length &&
content.includes(".") &&
content.length > 2
) {
const ctxItem = previousFileContextItemsRef.current.find(
(item) => item.uri!.value!.split("/").pop() === content, // Exact match for last segment of URI
);

if (ctxItem) {
const rif = ctxItemToRifWithContents(ctxItem);
return <FilenameLink rif={rif} />;
}
}

// Insert symbols for exact matches
Expand Down

0 comments on commit fcc4c99

Please sign in to comment.