Skip to content

Commit 641a262

Browse files
committed
fix: remove "block" from hunk keywords to avoid false positives
1 parent 63f1bd7 commit 641a262

6 files changed

Lines changed: 10 additions & 9 deletions

File tree

.claude-plugin/skills/revdiff/references/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,6 @@ don't remove this validation
152152

153153
Each annotation block: `## filename:line (type)` where type is `(+)` added, `(-)` removed, or `(file-level)`.
154154

155-
When annotation text contains keywords "hunk" or "block" (case-insensitive, whole word), the output header automatically expands to include the full hunk line range (e.g., `handler.go:43-67 (+)` instead of `handler.go:43 (+)`). This gives AI consumers the range context without any extra steps.
155+
When annotation text contains the keyword "hunk" (case-insensitive, whole word), the output header automatically expands to include the full hunk line range (e.g., `handler.go:43-67 (+)` instead of `handler.go:43 (+)`). This gives AI consumers the range context without any extra steps.
156156

157157
Use `--output` / `-o` flag to write annotations to a file instead of stdout.

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ TUI for reviewing diffs, files, and documents with inline annotations, built wit
1717
- `highlight/` - chroma-based syntax highlighting, foreground-only ANSI output
1818
- `keymap/` - user-configurable keybindings (`Action` constants, `Keymap` type, parser, defaults, dump)
1919
- `theme/` - color theme system: Parse (with hex validation), Load, List, Dump, InitBundled, BundledNames, ColorKeys (bundled: dracula, nord, solarized-dark)
20-
- `annotation/` - in-memory annotation store, structured output formatting; `Annotation.EndLine` enables hunk range headers when comment contains "hunk"/"block" keywords
20+
- `annotation/` - in-memory annotation store, structured output formatting; `Annotation.EndLine` enables hunk range headers when comment contains "hunk" keyword
2121
- `ui/mocks/` - moq-generated mocks (never edit manually)
2222

2323
## Key Interfaces (consumer-side, in `ui/`)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ refactor this hunk to reduce nesting
506506
don't remove this validation
507507
```
508508

509-
When annotation text contains keywords "hunk" or "block" (case-insensitive, whole word), the output header automatically expands to include the full hunk line range (e.g., `handler.go:43-67 (+)` instead of `handler.go:43 (+)`). This gives AI consumers the range context without any extra steps.
509+
When annotation text contains the keyword "hunk" (case-insensitive, whole word), the output header automatically expands to include the full hunk line range (e.g., `handler.go:43-67 (+)` instead of `handler.go:43 (+)`). This gives AI consumers the range context without any extra steps.
510510

511511
## Contributing
512512

site/docs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ <h2 id="output-format">Output format</h2>
437437
<span class="code-comment">## store.go:18 (-)</span>
438438
don't remove this validation</code></div>
439439
<p>Each annotation block: <code>## filename:line (type)</code> where type is <code>(+)</code> added, <code>(-)</code> removed, or <code>(file-level)</code>.</p>
440-
<p>When annotation text contains keywords &ldquo;hunk&rdquo; or &ldquo;block&rdquo; (case-insensitive, whole word), the output header automatically expands to include the full hunk line range (e.g., <code>handler.go:43-67 (+)</code> instead of <code>handler.go:43 (+)</code>). This gives AI consumers the range context without any extra steps.</p>
440+
<p>When annotation text contains the keyword &ldquo;hunk&rdquo; (case-insensitive, whole word), the output header automatically expands to include the full hunk line range (e.g., <code>handler.go:43-67 (+)</code> instead of <code>handler.go:43 (+)</code>). This gives AI consumers the range context without any extra steps.</p>
441441

442442
<h2 id="integration">Integration with other tools</h2>
443443
<p>The structured stdout output works with any tool that can read text:</p>

ui/annotate.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import (
1212
"github.com/umputun/revdiff/diff"
1313
)
1414

15-
// hunkKeywordRe matches whole-word "hunk" or "block" (case-insensitive).
16-
var hunkKeywordRe = regexp.MustCompile(`(?i)\b(hunk|block)\b`)
15+
// hunkKeywordRe matches whole-word "hunk" (case-insensitive).
16+
// "block" was removed as it triggers false positives in casual usage (e.g., "this code block is fine").
17+
var hunkKeywordRe = regexp.MustCompile(`(?i)\bhunk\b`)
1718

1819
// newAnnotationInput creates and focuses a text input for annotation editing.
1920
// prefixWidth accounts for the visible prefix characters (cursor col + emoji + label + margin).

ui/model_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -963,20 +963,20 @@ func TestModel_AnnotateHunkKeywordSetsEndLine(t *testing.T) {
963963
assert.Equal(t, 3, anns[0].EndLine, "EndLine should be last add line's NewNum")
964964
})
965965

966-
t.Run("block keyword on single remove in mixed hunk", func(t *testing.T) {
966+
t.Run("block is not a hunk keyword", func(t *testing.T) {
967967
m := testModel([]string{"a.go"}, nil)
968968
m.tree = newFileTree([]string{"a.go"})
969969
m.focus = paneDiff
970970
m.currFile = "a.go"
971971
m.diffLines = lines
972-
m.diffCursor = 1 // on "old line" (remove, OldNum=2) — only one remove in this hunk
972+
m.diffCursor = 1 // on "old line" (remove, OldNum=2)
973973
m.startAnnotation()
974974
m.annotateInput.SetValue("review this BLOCK carefully")
975975
m.saveAnnotation()
976976
anns := m.store.Get("a.go")
977977
require.Len(t, anns, 1)
978978
assert.Equal(t, 2, anns[0].Line)
979-
assert.Equal(t, 0, anns[0].EndLine, "single remove line, no multi-line range")
979+
assert.Equal(t, 0, anns[0].EndLine, "block is not a hunk keyword, no range expansion")
980980
})
981981

982982
t.Run("no keyword does not set EndLine", func(t *testing.T) {

0 commit comments

Comments
 (0)