Skip to content

Add optional label support for highlights with hover tooltip - #101

Open
IngDanielALH wants to merge 4 commits into
ryu1kn:masterfrom
IngDanielALH:feat/highlight-labels
Open

Add optional label support for highlights with hover tooltip#101
IngDanielALH wants to merge 4 commits into
ryu1kn:masterfrom
IngDanielALH:feat/highlight-labels

Conversation

@IngDanielALH

Copy link
Copy Markdown

Summary

Adds an optional label to highlights, shown as a hover tooltip over the highlighted text — useful for annotating why something is marked (e.g. transaction_id, TODO, CNBV-01) without leaving the editor.

  • New command "Toggle Highlight with Label" (textmarker.toggleHighlightWithLabel): prompts for a label when creating a highlight; pressing Esc cancels without decorating. Available on the right-click menu (toggleable via textmarker.commandsOnContextMenu, on by default) and via the command palette.
  • The label renders as a Markdown hover tooltip over the highlighted text.
  • "Update Highlight" now exposes an "Update Label" action in its quick pick, so an existing highlight's label can be edited or removed without recreating it.
  • Labels are persisted in textmarker.savedHighlights, so they survive editor reloads.
  • Decoration gained an optional label field; DecorationRegistry#issue, DecorationOperator#addDecoration, and TextEditor#setDecorations were extended to thread it through.

Why

Plain highlights are great for spotting patterns, but they don't carry any context about why a piece of text was marked. A label turns a highlight into a lightweight, inline annotation — handy for code review notes, tracking related identifiers across a file, or leaving reminders tied to specific text.

Test plan

  • npm test — 139 passing (135 existing + 4 new), no regressions
  • tslint -p . — clean
  • Manually verified in the Extension Development Host:
    • Selecting text → Toggle Highlight with Label → entering a label decorates the text and shows the label on hover
    • Cancelling the label prompt (Esc) leaves the text undecorated
    • Re-invoking the command on an existing label-highlight removes it
    • Update Highlight → Update Label edits the label of an existing highlight
  • New unit suite: src/test/unit/commands/toggle-highlight-with-label.test.ts covers: labeling a new selection, cancelling the prompt, toggling off an existing highlight (no prompt shown), and the no-selection no-op case
  • Existing suites updated where the setDecorations/addDecoration signatures gained the new optional label parameter

Notes for the maintainer

  • Context menu group ordering (2_textmarker@N) was renumbered to fit the new command in right after Toggle Highlight; behaviour of existing entries is unchanged, only their position.
  • textmarker.commandsOnContextMenu config gained toggleHighlightWithLabel (schema + default true), matching the pattern of the other toggleable context-menu entries.
  • Happy to split this into smaller commits or squash, whichever you prefer for review.

IngDanielALH and others added 4 commits July 7, 2026 18:54
- Decoration entity now supports optional label field
- New command "Toggle Highlight with Label" prompts for a label; Esc cancels the whole operation
- Hover tooltip renders label as Markdown (MarkdownString) on decorated text
- updateHighlight now exposes "Update Label" action in its quick pick menu
- Label is serialized/deserialized in savedHighlights for persistence across reloads
- All existing tests updated to match new setDecorations/addDecoration signatures

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Label to commandsOnContextMenu schema

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers labeling a new highlight, cancelling the label prompt,
toggling off an existing highlight without prompting, and the
no-selection no-op case.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
package-lock.json isn't used by this project (it relies on yarn.lock
and yarn-based scripts) and yarn.lock had drifted to resolve packages
from npmjs.org instead of yarnpkg.com with no actual dependency
changes — both were noise left over from local tooling, not part of
the label feature.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant