Skip to content

Commit 7c36a5f

Browse files
committed
fix: refine current folder suggestion display
1 parent 2e274ce commit 7c36a5f

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

src/engine/TemplateChoiceEngine.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,9 @@ export class TemplateChoiceEngine extends TemplateEngine {
309309
const parent = activeFile?.parent;
310310
if (!activeFile || !parent) return null;
311311
const path = parent.path ?? "";
312-
const displayPath = path ? path : "/";
313312
return {
314313
path,
315-
label: `<current folder> (${displayPath})`,
314+
label: "<current folder>",
316315
};
317316
}
318317
}

src/engine/TemplateEngine.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,37 @@ export abstract class TemplateEngine extends QuickAddEngine {
254254
displayByNormalized: Map<string, string>,
255255
): void {
256256
el.empty();
257+
el.classList.add("qaFileSuggestionItem");
257258
const normalized = this.normalizeFolderPath(item);
258259
const display = displayByNormalized.get(normalized);
259-
if (display) {
260-
el.setText(display);
261-
return;
260+
const displayPath = item || "/";
261+
const isExisting = existingSet.has(normalized);
262+
const mainText = display ?? displayPath;
263+
const subText = display && display !== displayPath
264+
? displayPath
265+
: !isExisting
266+
? "Create folder"
267+
: "";
268+
269+
const content = el.createDiv("qa-suggestion-content");
270+
content.createSpan({
271+
cls: "suggestion-main-text",
272+
text: mainText,
273+
});
274+
275+
if (!isExisting) {
276+
content.createSpan({
277+
cls: "qa-suggestion-pill qa-create-pill",
278+
text: "create",
279+
});
262280
}
263281

264-
if (existingSet.has(normalized)) {
265-
el.setText(item);
266-
return;
282+
if (subText) {
283+
el.createSpan({
284+
cls: "suggestion-sub-text",
285+
text: subText,
286+
});
267287
}
268-
269-
el.setText(`Create folder: ${item}`);
270288
}
271289

272290
protected async getFormattedFilePath(

0 commit comments

Comments
 (0)