Skip to content

Commit 93d11c0

Browse files
committed
refactor(context-menu): handle filename display better
1 parent 923e391 commit 93d11c0

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

webview-ui/src/components/chat/ContextMenu.tsx

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,37 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
109109
case ContextMenuOptionType.OpenedFile:
110110
case ContextMenuOptionType.Folder:
111111
if (option.value) {
112+
// remove trailing slash
113+
const path = removeLeadingNonAlphanumeric(option.value || "").replace(/\/$/, "")
114+
const filename = path.split("/").at(-1)
115+
const folderPath = path.split("/").slice(0, -1).join("/")
112116
return (
113-
<>
114-
<span>/</span>
115-
{option.value?.startsWith("/.") && <span>.</span>}
117+
<div
118+
style={{
119+
flex: 1,
120+
overflow: "hidden",
121+
display: "flex",
122+
gap: "0.5em",
123+
whiteSpace: "nowrap",
124+
alignItems: "center",
125+
justifyContent: "space-between",
126+
textAlign: "left",
127+
}}>
128+
<span>{filename}</span>
116129
<span
117130
style={{
118131
whiteSpace: "nowrap",
119132
overflow: "hidden",
120133
textOverflow: "ellipsis",
121134
direction: "rtl",
122-
textAlign: "left",
135+
textAlign: "right",
136+
flex: 1,
137+
opacity: 0.75,
138+
fontSize: "0.75em",
123139
}}>
124-
{removeLeadingNonAlphanumeric(option.value || "") + "\u200E"}
140+
{folderPath}
125141
</span>
126-
</>
142+
</div>
127143
)
128144
} else {
129145
return <span>Add {option.type === ContextMenuOptionType.File ? "File" : "Folder"}</span>
@@ -189,10 +205,9 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
189205
key={`${option.type}-${option.value || index}`}
190206
onClick={() => isOptionSelectable(option) && onSelect(option.type, option.value)}
191207
style={{
192-
padding: "8px 12px",
208+
padding: "4px 6px",
193209
cursor: isOptionSelectable(option) ? "pointer" : "default",
194210
color: "var(--vscode-dropdown-foreground)",
195-
borderBottom: "1px solid var(--vscode-editorGroup-border)",
196211
display: "flex",
197212
alignItems: "center",
198213
justifyContent: "space-between",
@@ -232,7 +247,7 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
232247
!option.value && (
233248
<i
234249
className="codicon codicon-chevron-right"
235-
style={{ fontSize: "14px", flexShrink: 0, marginLeft: 8 }}
250+
style={{ fontSize: "10px", flexShrink: 0, marginLeft: 8 }}
236251
/>
237252
)}
238253
{(option.type === ContextMenuOptionType.Problems ||
@@ -244,15 +259,15 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
244259
option.value)) && (
245260
<i
246261
className="codicon codicon-add"
247-
style={{ fontSize: "14px", flexShrink: 0, marginLeft: 8 }}
262+
style={{ fontSize: "10px", flexShrink: 0, marginLeft: 8 }}
248263
/>
249264
)}
250265
</div>
251266
))
252267
) : (
253268
<div
254269
style={{
255-
padding: "12px",
270+
padding: "4px",
256271
display: "flex",
257272
alignItems: "center",
258273
justifyContent: "center",

0 commit comments

Comments
 (0)