mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Fixes #5139: Improve YAML error line number extraction for .roomodes files
- Enhanced line number extraction in CustomModesManager to handle multiple YAML error message formats - Added support for patterns: 'at line X', 'line X', '(line:column)', and 'line:column' - Ensures robust error reporting when .roomodes files have YAML syntax errors - Maintains backward compatibility with existing error handling
This commit is contained in:
parent
3a8ba27615
commit
445cd63577
1 changed files with 17 additions and 2 deletions
|
|
@ -134,8 +134,23 @@ export class CustomModesManager {
|
|||
const errorMsg = yamlError instanceof Error ? yamlError.message : String(yamlError)
|
||||
console.error(`[CustomModesManager] Failed to parse YAML from ${filePath}:`, errorMsg)
|
||||
|
||||
const lineMatch = errorMsg.match(/at line (\d+)/)
|
||||
const line = lineMatch ? lineMatch[1] : "unknown"
|
||||
// Try multiple patterns to extract line number from YAML error messages
|
||||
const linePatterns = [
|
||||
/at line (\d+)/, // "at line X"
|
||||
/line (\d+)/, // "line X"
|
||||
/\((\d+):\d+\)/, // "(line:column)"
|
||||
/(\d+):\d+/, // "line:column"
|
||||
]
|
||||
|
||||
let line = "unknown"
|
||||
for (const pattern of linePatterns) {
|
||||
const match = errorMsg.match(pattern)
|
||||
if (match) {
|
||||
line = match[1]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
vscode.window.showErrorMessage(t("common:customModes.errors.yamlParseError", { line }))
|
||||
|
||||
// Return empty object to prevent duplicate error handling
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue