Skip to content

Commit 1b9252f

Browse files
author
Dante
committed
feat: add visual highlighting for TODO comments based on priority
1 parent d166636 commit 1b9252f

File tree

6 files changed

+341
-6
lines changed

6 files changed

+341
-6
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ Todas as mudanças notáveis do "TODO Board" serão documentadas neste arquivo.
55
O formato é baseado em [Keep a Changelog](http://keepachangelog.com/).
66

77

8+
## [1.3.0] - 2025-11-05
9+
10+
### ✨ Novas Funcionalidades
11+
12+
- **Destaque de TODOs no Editor** - Comentários TODO agora são destacados visualmente no código
13+
- Cores baseadas em prioridade:
14+
- 🔴 **Alta** (`@TODO(high)`) - Vermelho
15+
- 🟠 **Média** (`@TODO(medium)`) - Laranja
16+
- 🔵 **Baixa/Padrão** (`@TODO(low)` ou `@TODO`) - Azul
17+
- Configurável: ative/desative ou customize as cores
18+
- Funciona com todos os patterns de busca configurados
19+
- Atualização em tempo real conforme você digita
20+
- Indicadores na barra de rolagem (overview ruler)
21+
822
## [1.2.0] - 2025-11-04
923

1024
### 🔧 Refatoração

package.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "todo-board",
33
"displayName": "TODO Board",
44
"description": "Organize seus TODOs em um quadro Kanban visual com prioridades, labels e busca customizável",
5-
"version": "1.2.0",
5+
"version": "1.3.0",
66
"publisher": "dantewebmaster",
77
"repository": {
88
"type": "git",
@@ -154,6 +154,26 @@
154154
"@TODO"
155155
],
156156
"description": "Padrões de busca para TODOs. Exemplos: '@TODO', 'TODO', '@FIXME', 'FIXME', 'BUG'. Não inclua parênteses ou caracteres especiais de regex."
157+
},
158+
"todo-board.highlight.enabled": {
159+
"type": "boolean",
160+
"default": true,
161+
"description": "Ativar destaque visual de comentários TODO no editor"
162+
},
163+
"todo-board.highlight.highPriorityColor": {
164+
"type": "string",
165+
"default": "#e74c3c",
166+
"description": "Cor para TODOs de alta prioridade (@TODO(high))"
167+
},
168+
"todo-board.highlight.mediumPriorityColor": {
169+
"type": "string",
170+
"default": "#ffa94d",
171+
"description": "Cor para TODOs de média prioridade (@TODO(medium))"
172+
},
173+
"todo-board.highlight.lowPriorityColor": {
174+
"type": "string",
175+
"default": "#4dabf7",
176+
"description": "Cor para TODOs de baixa prioridade ou sem prioridade (@TODO(low) ou @TODO)"
157177
}
158178
}
159179
}

src/constants/regex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Centralized regex and markers for scanners
22
const TODO_PATTERN: RegExp = /@TODO(?:\([^)]*\))?/;
3-
const LABEL_PATTERN: RegExp = /\[(.*?)\]/;
3+
const LABEL_PATTERN: RegExp = /\[([^\]]*)\]/s; // Added 's' flag to match across newlines
44
const PRIORITY_REGEX: RegExp = /^@TODO(?:\(([^)]+)\))?/i;
55

66
const LINE_BREAK_REGEX: RegExp = /\r\n|\n/g;

src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { insertTodoComment } from "@/commands/insert-todo";
66
import { openTodoBoard } from "@/commands/open-board";
77
import { scanTodos } from "@/commands/scan-todos";
88
import { initializeStorage } from "@/services/storage";
9+
import { initializeTodoDecorator } from "@/services/todo-decorator";
910
import { registerTodoSidebar } from "@/ui/sidebar";
1011

1112
export function activate(context: vscode.ExtensionContext) {
@@ -14,6 +15,9 @@ export function activate(context: vscode.ExtensionContext) {
1415
// Initialize storage service
1516
initializeStorage(context);
1617

18+
// Initialize TODO comment highlighting
19+
initializeTodoDecorator(context);
20+
1721
const scanCmd = vscode.commands.registerCommand(
1822
"todo-board.scanTodos",
1923
scanTodos,

src/services/scanner.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export async function scanWorkspace(
7575
return { text: combined, endIndex };
7676
}
7777

78-
if (isBlockStartWithoutEnd(lineText)) {
78+
if (isBlockStartWithoutEnd(lineText) || isInsideBlock(lineText)) {
7979
const { combinedSuffix, endIndex } = collectBlockContinuation(
8080
doc,
8181
index + 1,
@@ -342,9 +342,9 @@ function collectContinuation(
342342
}
343343

344344
function stripBlockLinePrefix(text: string): string {
345-
// Remove '/**', '/*' or leading '*' with one optional following space
346-
// Prefer explicit pattern to handle both cases consistently
347-
return text.replace(/^\s*(?:\/\*\*?|\*)\s?/, "");
345+
// Remove '/**', '/*' or leading '*' with all following spaces
346+
// This ensures labels like [tag] are preserved in block comments
347+
return text.replace(/^\s*(?:\/\*\*?|\*)\s*/, "");
348348
}
349349

350350
function isHtmlBlockStartWithoutEnd(text: string): boolean {
@@ -361,6 +361,16 @@ function isBlockStartWithoutEnd(text: string): boolean {
361361
);
362362
}
363363

364+
function isInsideBlock(text: string): boolean {
365+
// Detect if line is inside a block comment (starts with * but not /* or */)
366+
const trimmed = text.trimStart();
367+
return (
368+
trimmed.startsWith("*") &&
369+
!trimmed.startsWith("/*") &&
370+
!trimmed.startsWith("*/")
371+
);
372+
}
373+
364374
function isTodoLine(
365375
text: string,
366376
matchPattern: RegExp,

0 commit comments

Comments
 (0)