feat:解决添加上下文搜索选择文件不匹配的问题

This commit is contained in:
Roe-xin
2026-03-02 15:43:33 +08:00
parent f700473967
commit 9ed0afee6b
2 changed files with 60 additions and 30 deletions

View File

@ -137,9 +137,12 @@ export function getContextDisplayScript(): string {
}
// 添加上下文项
function addContextItem(type, path) {
function addContextItem(type, path, displayPath) {
const exists = contextItems.some(item => item.type === type && item.path === path);
if (exists) return;
const id = Date.now() + Math.random();
contextItems.push({ id, type, path });
contextItems.push({ id, type, path, displayPath: displayPath || '' });
renderContextItems();
}
@ -174,7 +177,7 @@ export function getContextDisplayScript(): string {
return \`
<div class="context-item" title="\${item.path}">
\${icon}
<span class="context-item-name">\${getFileName(item.path)}</span>
<span class="context-item-name">\${item.displayPath || getFileName(item.path)}</span>
<span class="context-item-remove" onclick="removeContextItem(\${item.id})">
\${getRemoveIcon()}
</span>