fixed regression where priority was still listed raw before task

This commit is contained in:
specCon18 2025-03-18 17:21:01 -04:00
parent 209925146e
commit 29b746235c

View file

@ -85,11 +85,16 @@ func extractPriority(line string) (int, error) {
return 9, nil // Default priority if none is found return 9, nil // Default priority if none is found
} }
// Function to extract the task from the TODO comment // Function to extract the task from the TODO comment and remove the priority
func extractTask(line string) string { func extractTask(line string) string {
trimmedLine := strings.TrimSpace(line) trimmedLine := strings.TrimSpace(line)
trimmedLine = strings.TrimPrefix(trimmedLine, "//TODO: ") trimmedLine = strings.TrimPrefix(trimmedLine, "//TODO: ")
return strings.TrimSpace(trimmedLine)
// Remove the priority part (P:<digit>) if it exists
re := regexp.MustCompile(`P:\d+`)
trimmedLine = re.ReplaceAllString(trimmedLine, "")
return strings.TrimSpace(trimmedLine) // Return the task without priority
} }
//TODO: P:0 add support for TODO's not at start of line //TODO: P:0 add support for TODO's not at start of line