From 0d2f4b3c6682270246b6c32149b3a3d1383ed68e Mon Sep 17 00:00:00 2001 From: sam hoang Date: Sun, 13 Apr 2025 22:03:29 +0700 Subject: [PATCH 1/2] Refactor: Replace path.basename with custom getBasename function for label formatting --- webview-ui/src/utils/context-mentions.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webview-ui/src/utils/context-mentions.ts b/webview-ui/src/utils/context-mentions.ts index e783f4c625..77de6e2716 100644 --- a/webview-ui/src/utils/context-mentions.ts +++ b/webview-ui/src/utils/context-mentions.ts @@ -1,7 +1,10 @@ import { mentionRegex } from "@roo/shared/context-mentions" import { Fzf } from "fzf" import { ModeConfig } from "@roo/shared/modes" -import * as path from "path" + +function getBasename(filepath: string): string { + return filepath.split("/").pop() || filepath +} import { escapeSpaces } from "./path-mentions" export interface SearchResult { @@ -254,7 +257,7 @@ export function getContextMenuOptions( // For display purposes, we don't escape spaces in the label or description const displayPath = formattedPath - const displayName = result.label || path.basename(result.path) + const displayName = result.label || getBasename(result.path) // We don't need to escape spaces here because the insertMention function // will handle that when the user selects a suggestion From d5922fe28e6f4eea43a1e6f9be4d906d65e70f77 Mon Sep 17 00:00:00 2001 From: sam hoang Date: Tue, 6 May 2025 19:33:30 +0700 Subject: [PATCH 2/2] refactor: Replace path.basename with custom getBasename function for label formatting --- webview-ui/src/utils/context-mentions.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/webview-ui/src/utils/context-mentions.ts b/webview-ui/src/utils/context-mentions.ts index 77de6e2716..8257be7ecb 100644 --- a/webview-ui/src/utils/context-mentions.ts +++ b/webview-ui/src/utils/context-mentions.ts @@ -2,9 +2,6 @@ import { mentionRegex } from "@roo/shared/context-mentions" import { Fzf } from "fzf" import { ModeConfig } from "@roo/shared/modes" -function getBasename(filepath: string): string { - return filepath.split("/").pop() || filepath -} import { escapeSpaces } from "./path-mentions" export interface SearchResult { @@ -12,6 +9,11 @@ export interface SearchResult { type: "file" | "folder" label?: string } + +function getBasename(filepath: string): string { + return filepath.split("/").pop() || filepath +} + export function insertMention( text: string, position: number,