Skip to content

Suppress line numbers in edit/read tools: 1→Line 1 to Line 1#326

Merged
bl-ue merged 4 commits intomainfrom
suppress-line-numbers
Jan 2, 2026
Merged

Suppress line numbers in edit/read tools: 1→Line 1 to Line 1#326
bl-ue merged 4 commits intomainfrom
suppress-line-numbers

Conversation

@basekevin
Copy link
Member

@basekevin basekevin commented Jan 1, 2026

Closes #310

Summary by CodeRabbit

  • New Features

    • Added a miscellaneous setting to suppress line-number display (enabled by default).
    • Settings panel includes a toggle to enable/disable showing line numbers.
    • When enabled, edited/read content is shown without line-number prefixes.
  • Documentation

    • Changelog updated with an entry describing the line-number suppression change.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 1, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds a new misc setting suppressLineNumbers (default true), a patch that strips an inline line-number formatter from file content, type/default updates, integration of the patch into applyCustomization, and a UI toggle to control the behavior.

Changes

Cohort / File(s) Summary
Configuration & Types
\src/defaultSettings.ts`, `src/types.ts``
Add suppressLineNumbers: boolean to DEFAULT_SETTINGS and MiscConfig (default true).
Patch Implementation
\src/patches/suppressLineNumbers.ts``
New patch writer writeSuppressLineNumbers(oldFile) that locates a line-number formatter via regex, replaces the formatter block with return <contentVar>, emits a diff via showDiff, and returns modified content or null; logs errors on failure.
Patch Integration
\src/patches/index.ts``
Import and conditionally invoke the new patch inside applyCustomization() when config.settings.misc?.suppressLineNumbers is truthy (applied after increaseFileReadLimit, before writing).
UI
\src/ui/components/MiscView.tsx``
Add a toggle UI item for suppressLineNumbers with getValue defaulting to true and setter that ensures misc exists before toggling.
Changelog
\CHANGELOG.md``
Document "Suppress line numbers in edit/read tools" under Unreleased.
sequenceDiagram
  autonumber
  participant Config as UserConfig
  participant Patcher as applyCustomization()
  participant Suppress as suppressLineNumbers
  participant FS as FileSystem

  rect rgb(237,247,237)
    note right of Config: Feature flag check
  end

  Config->>Patcher: call applyCustomization(config, oldFile)
  alt suppressLineNumbers enabled
    Patcher->>Suppress: call writeSuppressLineNumbers(oldFile)
    Suppress->>FS: inspect content (regex locate formatter)
    Suppress-->>Patcher: return modifiedContent or null
    alt modifiedContent returned
      Patcher->>FS: write modifiedContent
    else null
      Patcher-->>FS: leave content unchanged
    end
  else disabled
    Patcher-->>FS: skip suppression
  end
  Patcher-->>Config: finish
Loading

🎯 3 (Moderate) | ⏱️ ~22 minutes

🐰 I hop through code with nimble paws,
Removing arrows that clutter the clause,
Lines now speak plain without a trace,
Tokens breathe easier, calm in their space,
A gentle nibble, a tidy cause.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: suppressing line numbers in edit/read tools by removing the numeric prefix format.
Linked Issues check ✅ Passed The PR implementation meets all coding requirements from issue #310: adds suppressLineNumbers setting, implements patching logic to remove line-number formatting, and exposes the option in UI.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the suppressLineNumbers feature requested in issue #310; no unrelated modifications detected.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e1bd9a and 0247542.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • src/patches/index.ts

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 254d033 and ce3feac.

📒 Files selected for processing (5)
  • src/defaultSettings.ts
  • src/patches/index.ts
  • src/patches/suppressLineNumbers.ts
  • src/types.ts
  • src/ui/components/MiscView.tsx
🧰 Additional context used
🧬 Code graph analysis (2)
src/patches/suppressLineNumbers.ts (1)
src/patches/index.ts (2)
  • LocationResult (70-74)
  • showDiff (88-126)
src/patches/index.ts (1)
src/patches/suppressLineNumbers.ts (1)
  • writeSuppressLineNumbers (51-72)
🔇 Additional comments (7)
src/defaultSettings.ts (1)

756-756: LGTM!

The new suppressLineNumbers setting is correctly added with a default value of true, aligning with the PR objectives to suppress line number prefixes by default.

src/ui/components/MiscView.tsx (1)

34-34: LGTM!

The default value of true correctly matches the default in src/defaultSettings.ts.

src/types.ts (1)

116-116: LGTM!

The type definition correctly adds the new suppressLineNumbers boolean field to MiscConfig, consistent with other miscellaneous settings.

src/patches/index.ts (2)

63-63: LGTM!

The import follows the established pattern for patch writers in this file.


661-664: LGTM!

The patch application logic correctly applies the suppressLineNumbers patch conditionally based on the configuration setting. The placement after increaseFileReadLimit and the pattern match other conditional patches in the file.

src/patches/suppressLineNumbers.ts (2)

51-72: LGTM!

The function correctly implements the suppression logic:

  1. Locates the line number formatter using the regex pattern
  2. Extracts the content variable name from the second capture group
  3. Replaces the entire formatter block with a simple return ${contentVar} statement
  4. Provides appropriate error handling and debugging output

This effectively removes line number prefixes (e.g., 1→content) and returns only the content, achieving the PR's objective to reduce token usage.


14-49: Regex pattern is syntactically correct and matches the intended minified format.

The regex on line 33 successfully captures both the line number variable and content variable. The pattern correctly uses ([$\w]+) to handle identifiers with dollar signs per the patch guidelines in index.ts.

Optional: Consider adding a word boundary \b at the start of the pattern (/\bif\() for performance optimization, as noted in the patch infrastructure guidelines (lines 28-32 of index.ts).

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@bl-ue bl-ue merged commit 14addaa into main Jan 2, 2026
1 check passed
@bl-ue bl-ue deleted the suppress-line-numbers branch January 2, 2026 18:43
@coderabbitai coderabbitai bot mentioned this pull request Feb 3, 2026
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.

Feature request: Suppress line numbers in file reads and edits [patch]

2 participants