feat: 优化上下文项显示和识别逻辑
- 支持显示所有类型的上下文项(文件和代码片段) - 增强路径识别,支持代码片段格式(文件名:行号-行号)
This commit is contained in:
@ -432,15 +432,14 @@ export function getInputAreaScript(): string {
|
||||
// 获取上下文项
|
||||
const contextItems = window.getContextItems ? window.getContextItems() : [];
|
||||
|
||||
// 构建显示消息:如果有上下文文件,添加文件路径前缀
|
||||
// 构建显示消息:如果有上下文项,添加路径前缀
|
||||
let displayText = text;
|
||||
if (contextItems.length > 0) {
|
||||
const filePaths = contextItems
|
||||
.filter(item => item.type === 'file')
|
||||
const contextPaths = contextItems
|
||||
.map(item => item.displayPath || item.path)
|
||||
.join(' ');
|
||||
if (filePaths) {
|
||||
displayText = filePaths + ' ' + text;
|
||||
if (contextPaths) {
|
||||
displayText = contextPaths + ' ' + text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -863,8 +863,8 @@ export function getMessageAreaScript(): string {
|
||||
const textParts = [];
|
||||
|
||||
parts.forEach(part => {
|
||||
// 判断是否为文件路径:包含路径分隔符或文件扩展名
|
||||
if (part.includes('/') || part.includes('\\\\') || /\\.[a-zA-Z0-9]+$/.test(part)) {
|
||||
// 判断是否为文件路径或代码片段:包含路径分隔符、文件扩展名或代码片段格式(文件名:行号-行号)
|
||||
if (part.includes('/') || part.includes('\\\\') || /\\.[a-zA-Z0-9]+$/.test(part) || /:[0-9]+-[0-9]+$/.test(part)) {
|
||||
filePaths.push(part);
|
||||
} else {
|
||||
textParts.push(part);
|
||||
|
||||
Reference in New Issue
Block a user