Skip to content

chore: lint and dupe fixes#30

Merged
csprasad merged 4 commits into
mainfrom
patch-1
Jun 14, 2026
Merged

chore: lint and dupe fixes#30
csprasad merged 4 commits into
mainfrom
patch-1

Conversation

@csprasad

@csprasad csprasad commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Refactor

    • Project structure reorganized and legacy tokenizer/syntax-rule components removed
    • Theme initialization/persistence reworked so both dark-mode preference and saved theme name influence startup
  • Style

    • Toolbar layout and spacing improved
    • General formatting and small UI refinements across the app
  • Performance

    • Editor highlighting flow improved for responsiveness and to preserve user selection during updates
  • Tests

    • Added coverage for regex literal tokenization

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Removes tokenizer sources and PBX wiring, simplifies theme persistence to isDarkMode-only, updates SyntaxHighlighter and CodeEditor async highlighting flow, refactors formatter and view-model wiring, adjusts UI/layout, and updates tests and Xcode build settings.

Changes

Tokenizer removal and theme/editor architecture refactoring

Layer / File(s) Summary
Project PBX and tokenizer wiring cleanup
DevLint.xcodeproj/project.pbxproj
Remove tokenizer-related file references/groups and update DevLint/DevLintTests source build phases; add UI/theme sources; update LastUpgradeCheck and add DEAD_CODE_STRIPPING, ENABLE_USER_SCRIPT_SANDBOXING, STRING_CATALOG_GENERATE_SYMBOLS settings.
ThemeManager, ThemeModel, and NSColor helper updates
DevLint/Core/ThemeManager.swift, DevLint/Models/ThemeModel.swift, DevLint/Utilities/Extensions/Extensions.swift
Change persisted theme-name visibility and initialization flow, keep isDarkMode; remove ThemeModel.secondaryColor; rename hex init component vars to red/green/blue/alpha.
SyntaxHighlighter API and CodeEditor async highlighting
DevLint/SyntaxHighlighting/SyntaxHighlighter.swift, DevLint/Components/CodeEditorView.swift
Drop appearance parameter from SyntaxHighlighter.highlight, reformat regex patterns; CodeEditorView preserves/restores selection, uses theme-only highlight API, and always reapplies theme colors/fonts on update.
Formatter, ViewModel, and container wiring changes
DevLint/Utilities/Formatters/CodeFormatter.swift, DevLint/Utilities/Formatters/SwiftFormatAdapter.swift, DevLint/ViewModels/CodeEditorViewModel.swift, DevLint/Views/CodeEditorContainer.swift, DevLint/Views/CodeOutputView.swift
FormatterManager no longer supports setFormatter(_); format error handling now returns original code silently; added docs. CodeEditorViewModel no longer injected with ThemeManager; container constructs it parameterlessly; small binding comment cleanup.
Toolbar, ContentView, and view polish
DevLint/Views/CustomToolbar.swift, DevLint/Views/ContentView.swift, DevLint/Views/EditorSectionView.swift, DevLint/Views/ToolbarButton.swift, DevLint/App/DevLintApp.swift
Refactor toolbar layout (dark-mode toggle multiline, separators), remove ContentView_Previews, and apply minor whitespace/comment formatting across views.
Tests reformat and template cleanup
DevLintTests/TokenizerTests.swift, DevLintTests/DevLintTests.swift
Reformat tokenizer tests and add testRegexLiterals; clear default XCTest template bodies in DevLintTests.

Sequence Diagram(s)

sequenceDiagram
  participant CodeEditorView
  participant NSTextView
  participant SyntaxHighlighter
  CodeEditorView->>NSTextView: synchronize bound text and capture selection
  CodeEditorView->>NSTextView: update theme colors & font
  CodeEditorView->>SyntaxHighlighter: highlight(attributedString, theme)
  SyntaxHighlighter-->>CodeEditorView: highlighted attributes
  CodeEditorView->>NSTextView: apply attributes and restore selection
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through tokens, trimmed the heap,

Themes tucked snug where secrets sleep,
Editors hum and colors blend,
Builds align as changes mend,
A tiny rabbit cheers the sweep.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.84% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'chore: lint and dupe fixes' is vague and generic, using non-descriptive terms that don't convey meaningful information about the substantial architectural changes made in this changeset. Replace with a more specific title that reflects the primary changes, such as 'refactor: remove tokenizer system and simplify syntax highlighting' or 'refactor: consolidate syntax highlighting and remove dead code'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch patch-1

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

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Note

Docstrings generation - SUCCESS
Generated docstrings and committed to branch patch-1 (commit: 2fce177a8980e9c8725acfcaaa9c19d6ff1b50ea)

Docstrings generation was requested by @csprasad.

The following files were modified:

* `DevLint/DevLint/Components/CodeEditorView.swift`
* `DevLint/DevLint/Core/ThemeManager.swift`
* `DevLint/DevLint/SyntaxHighlighting/SyntaxHighlighter.swift`
* `DevLint/DevLint/Utilities/Formatters/CodeFormatter.swift`
* `DevLint/DevLint/Utilities/Formatters/SwiftFormatAdapter.swift`
* `DevLint/DevLint/ViewModels/CodeEditorViewModel.swift`

These files were ignored:
* `DevLint/DevLintTests/DevLintTests.swift`
* `DevLint/DevLintTests/TokenizerTests.swift`

These file types are not supported:
* `DevLint/DevLint.xcodeproj/project.pbxproj`

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
DevLint/DevLint/Core/ThemeManager.swift (1)

84-87: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Apply the persisted appearance during initialization.

init() restores currentTheme from isDarkMode, but it never applies the matching NSApp.appearance. On launch with a persisted dark-mode preference, the editor theme becomes dark while the app chrome can stay in the default Aqua appearance until the user toggles the setting again.

Suggested fix
     init() {
         self.currentTheme = availableThemes[0]
         updateThemeForDarkMode()
+        applyAppearance()
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DevLint/DevLint/Core/ThemeManager.swift` around lines 84 - 87, The
initializer sets currentTheme from availableThemes and calls
updateThemeForDarkMode() but never applies the persisted app appearance; after
restoring currentTheme in init(), set NSApp.appearance according to the
persisted dark-mode flag (e.g., if isDarkMode or currentTheme indicates dark,
assign NSApp.appearance = NSAppearance(named: .darkAqua), otherwise set to nil
or NSAppearance(named: .aqua)) or call the existing theme-application routine
that applies window chrome; update init() to explicitly apply NSApp.appearance
so the app chrome matches currentTheme on launch.
DevLint/DevLint/Components/CodeEditorView.swift (1)

114-120: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Apply all editor colors/fonts unconditionally when the theme changes.

This guard keys the whole update off backgroundColor only. If the new theme shares the same background as the current NSTextView state, textColor, insertionPointColor, and font never refresh. That also leaves the initial "Default" theme partially unapplied when the view starts with the system white background.

Suggested fix
     private func updateThemeIfNeeded(for textView: NSTextView) {
-        if textView.backgroundColor != themeManager.currentTheme.backgroundColor {
-            textView.backgroundColor = themeManager.currentTheme.backgroundColor
-            textView.textColor = themeManager.currentTheme.primaryColor
-            textView.insertionPointColor = themeManager.currentTheme.primaryColor
-            textView.font = NSFont.monospacedSystemFont(ofSize: 14, weight: .regular)
-        }
+        textView.backgroundColor = themeManager.currentTheme.backgroundColor
+        textView.textColor = themeManager.currentTheme.primaryColor
+        textView.insertionPointColor = themeManager.currentTheme.primaryColor
+        textView.font = NSFont.monospacedSystemFont(ofSize: 14, weight: .regular)
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DevLint/DevLint/Components/CodeEditorView.swift` around lines 114 - 120, The
updateThemeIfNeeded(for:) method currently gates all updates on
textView.backgroundColor matching the theme, causing
textColor/insertionPointColor/font to not refresh; change it so the editor
colors and font are applied whenever the theme changes — either by removing the
backgroundColor conditional and always assigning textView.backgroundColor,
textView.textColor, textView.insertionPointColor, and textView.font from
themeManager.currentTheme, or by tracking the lastAppliedTheme (e.g., a stored
property) and comparing that to themeManager.currentTheme to decide when to
update; ensure you reference updateThemeIfNeeded(for:),
themeManager.currentTheme.backgroundColor/primaryColor, and the textView
property assignments when making the fix.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@DevLint/DevLintTests/TokenizerTests.swift`:
- Around line 13-120: The tests still reference the removed Tokenizer API
(constructing Tokenizer and using Token.TokenType via assertTokenization), so
either delete this test file or rewrite it to exercise the new
syntax-highlighting surface; specifically remove usages of Tokenizer,
Token.TokenType and assertTokenization as written, and replace them with calls
to the new highlighter interface (or unregister
DevLint/DevLintTests/TokenizerTests.swift from the DevLintTests target) so the
test bundle can compile.

---

Outside diff comments:
In `@DevLint/DevLint/Components/CodeEditorView.swift`:
- Around line 114-120: The updateThemeIfNeeded(for:) method currently gates all
updates on textView.backgroundColor matching the theme, causing
textColor/insertionPointColor/font to not refresh; change it so the editor
colors and font are applied whenever the theme changes — either by removing the
backgroundColor conditional and always assigning textView.backgroundColor,
textView.textColor, textView.insertionPointColor, and textView.font from
themeManager.currentTheme, or by tracking the lastAppliedTheme (e.g., a stored
property) and comparing that to themeManager.currentTheme to decide when to
update; ensure you reference updateThemeIfNeeded(for:),
themeManager.currentTheme.backgroundColor/primaryColor, and the textView
property assignments when making the fix.

In `@DevLint/DevLint/Core/ThemeManager.swift`:
- Around line 84-87: The initializer sets currentTheme from availableThemes and
calls updateThemeForDarkMode() but never applies the persisted app appearance;
after restoring currentTheme in init(), set NSApp.appearance according to the
persisted dark-mode flag (e.g., if isDarkMode or currentTheme indicates dark,
assign NSApp.appearance = NSAppearance(named: .darkAqua), otherwise set to nil
or NSAppearance(named: .aqua)) or call the existing theme-application routine
that applies window chrome; update init() to explicitly apply NSApp.appearance
so the app chrome matches currentTheme on launch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8a1ebb05-5431-43e2-a041-c9813f46c041

📥 Commits

Reviewing files that changed from the base of the PR and between 6f88560 and 012d6fa.

📒 Files selected for processing (22)
  • DevLint/DevLint.xcodeproj/project.pbxproj
  • DevLint/DevLint/App/DevLintApp.swift
  • DevLint/DevLint/Components/CodeEditorView.swift
  • DevLint/DevLint/Core/ThemeManager.swift
  • DevLint/DevLint/Models/CodeEditorModel.swift
  • DevLint/DevLint/Models/ThemeModel.swift
  • DevLint/DevLint/SyntaxHighlighting/SyntaxHighlighter.swift
  • DevLint/DevLint/SyntaxHighlighting/Tokenizer/LanguageRules.swift
  • DevLint/DevLint/SyntaxHighlighting/Tokenizer/SwiftLanguageRules.swift
  • DevLint/DevLint/SyntaxHighlighting/Tokenizer/Token.swift
  • DevLint/DevLint/SyntaxHighlighting/Tokenizer/Tokenizer.swift
  • DevLint/DevLint/Utilities/Extensions/Extensions.swift
  • DevLint/DevLint/Utilities/Formatters/CodeFormatter.swift
  • DevLint/DevLint/Utilities/Formatters/SwiftFormatAdapter.swift
  • DevLint/DevLint/ViewModels/CodeEditorViewModel.swift
  • DevLint/DevLint/Views/CodeEditorContainer.swift
  • DevLint/DevLint/Views/ContentView.swift
  • DevLint/DevLint/Views/CustomToolbar.swift
  • DevLint/DevLint/Views/EditorSectionView.swift
  • DevLint/DevLint/Views/ToolbarButton.swift
  • DevLint/DevLintTests/DevLintTests.swift
  • DevLint/DevLintTests/TokenizerTests.swift
💤 Files with no reviewable changes (8)
  • DevLint/DevLint/SyntaxHighlighting/Tokenizer/Token.swift
  • DevLint/DevLint/Views/ContentView.swift
  • DevLint/DevLintTests/DevLintTests.swift
  • DevLint/DevLint/Models/ThemeModel.swift
  • DevLint/DevLint/SyntaxHighlighting/Tokenizer/LanguageRules.swift
  • DevLint/DevLint/Models/CodeEditorModel.swift
  • DevLint/DevLint/SyntaxHighlighting/Tokenizer/SwiftLanguageRules.swift
  • DevLint/DevLint/SyntaxHighlighting/Tokenizer/Tokenizer.swift

Comment thread DevLint/DevLintTests/TokenizerTests.swift Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@DevLint/DevLint/Components/CodeEditorView.swift`:
- Around line 124-125: The doc comment above the method that updates a text
view's colors (the triple-slash comment describing "Updates the given text
view's colors and font..." and the "- Parameter textView: ..." line) has 8
spaces of indentation on the second line; change that line to match the standard
4-space indentation used by other doc comments in CodeEditorView.swift so the
comment block is consistently indented with the rest of the file.
- Line 71: Remove the leftover debug print statement that logs
themeManager.currentTheme.name (the line "print(themeManager.currentTheme.name +
\"theme on text bg\")") from CodeEditorView (where the view is created); simply
delete that print call (or replace it with a conditional debug-only logger if
needed) so it no longer executes on every view creation.

In `@DevLint/DevLint/ViewModels/CodeEditorViewModel.swift`:
- Around line 49-52: The clear() method currently resets inputCode and
formattedCode but leaves lineNumbers stale; update clear() in
CodeEditorViewModel to also reset/recompute the gutter by clearing or
regenerating lineNumbers (e.g., set lineNumbers = [] or call
updateLineNumbers()) so the editor shows zero lines immediately after clear;
reference the clear() function and the lineNumbers property and
updateLineNumbers() helper when making the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 67813209-9494-4785-a218-b17264dc2f30

📥 Commits

Reviewing files that changed from the base of the PR and between 012d6fa and 2fce177.

📒 Files selected for processing (6)
  • DevLint/DevLint/Components/CodeEditorView.swift
  • DevLint/DevLint/Core/ThemeManager.swift
  • DevLint/DevLint/SyntaxHighlighting/SyntaxHighlighter.swift
  • DevLint/DevLint/Utilities/Formatters/CodeFormatter.swift
  • DevLint/DevLint/Utilities/Formatters/SwiftFormatAdapter.swift
  • DevLint/DevLint/ViewModels/CodeEditorViewModel.swift

Comment thread DevLint/DevLint/Components/CodeEditorView.swift Outdated
Comment thread DevLint/DevLint/Components/CodeEditorView.swift Outdated
Comment thread DevLint/DevLint/ViewModels/CodeEditorViewModel.swift

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
DevLint/DevLint/Core/ThemeManager.swift (2)

84-87: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Apply the persisted appearance during initialization.

When isDarkMode is already true in AppStorage, init() switches currentTheme to "Dark" but never calls applyAppearance(), so the editor theme and the app chrome can start out mismatched until the toggle changes again. Call applyAppearance() once after restoring the initial theme.

Suggested fix
     init() {
         self.currentTheme = availableThemes[0]
         updateThemeForDarkMode()
+        applyAppearance()
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DevLint/DevLint/Core/ThemeManager.swift` around lines 84 - 87, The
initializer sets self.currentTheme from availableThemes[0] and calls
updateThemeForDarkMode() but doesn't apply the restored appearance, so when
isDarkMode (AppStorage) is true the UI can be out of sync; after
updateThemeForDarkMode() in init() call applyAppearance() to ensure the editor
theme and app chrome are applied immediately (referencing init(), currentTheme,
availableThemes, updateThemeForDarkMode(), applyAppearance(), and isDarkMode).

13-17: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Persisting only isDarkMode regresses theme restoration.

CustomToolbar still lets users pick "Solarized" via $themeManager.currentTheme, but this manager now restores state from isDarkMode alone, so every non-Default/Dark selection is lost on relaunch. If this PR intentionally collapses themes down to light/dark only, the picker should be constrained to match; otherwise the selected theme name still needs persistence.

Suggested fix
 class ThemeManager: ObservableObject {
     `@Published` var currentTheme: ThemeModel
+    `@AppStorage`("selectedThemeName") private var selectedThemeName: String = "Default"
     `@AppStorage`("isDarkMode") var isDarkMode: Bool = false {
         didSet {
             updateThemeForDarkMode()
             applyAppearance()
         }
@@
     init() {
         self.currentTheme = availableThemes[0]
-        updateThemeForDarkMode()
+        setTheme(name: selectedThemeName)
+        applyAppearance()
     }
@@
     func setTheme(name: String) {
         if let newTheme = availableThemes.first(where: { $0.name == name }) {
             currentTheme = newTheme
+            selectedThemeName = name
         }
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DevLint/DevLint/Core/ThemeManager.swift` around lines 13 - 17, Theme
restoration regresses because ThemeManager now only persists
`@AppStorage`("isDarkMode") isDarkMode and ignores the selected theme used by
CustomToolbar via $themeManager.currentTheme; restore the selected theme by
persisting the theme identifier (e.g., add `@AppStorage`("currentThemeName") var
currentThemeName: String? or similar) and update ThemeManager's init/restore
path to set currentTheme from that stored name (or, if the design intentionally
collapses to light/dark, restrict the CustomToolbar picker to only Default/Dark
and remove references to non-binary themes); update
updateThemeForDarkMode/applyAppearance to respect the persisted currentThemeName
when present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@DevLint/DevLint/Core/ThemeManager.swift`:
- Around line 84-87: The initializer sets self.currentTheme from
availableThemes[0] and calls updateThemeForDarkMode() but doesn't apply the
restored appearance, so when isDarkMode (AppStorage) is true the UI can be out
of sync; after updateThemeForDarkMode() in init() call applyAppearance() to
ensure the editor theme and app chrome are applied immediately (referencing
init(), currentTheme, availableThemes, updateThemeForDarkMode(),
applyAppearance(), and isDarkMode).
- Around line 13-17: Theme restoration regresses because ThemeManager now only
persists `@AppStorage`("isDarkMode") isDarkMode and ignores the selected theme
used by CustomToolbar via $themeManager.currentTheme; restore the selected theme
by persisting the theme identifier (e.g., add `@AppStorage`("currentThemeName")
var currentThemeName: String? or similar) and update ThemeManager's init/restore
path to set currentTheme from that stored name (or, if the design intentionally
collapses to light/dark, restrict the CustomToolbar picker to only Default/Dark
and remove references to non-binary themes); update
updateThemeForDarkMode/applyAppearance to respect the persisted currentThemeName
when present.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a8cb9632-656d-4e69-aa05-5a34a57f2add

📥 Commits

Reviewing files that changed from the base of the PR and between 2fce177 and 408cd91.

📒 Files selected for processing (7)
  • DevLint/DevLint.xcodeproj/project.pbxproj
  • DevLint/DevLint/Components/CodeEditorView.swift
  • DevLint/DevLint/Core/ThemeManager.swift
  • DevLint/DevLint/Models/ThemeModel.swift
  • DevLint/DevLint/Utilities/Formatters/CodeFormatter.swift
  • DevLint/DevLint/Views/CodeOutputView.swift
  • DevLint/DevLintTests/TokenizerTests.swift
💤 Files with no reviewable changes (5)
  • DevLint/DevLint/Models/ThemeModel.swift
  • DevLint/DevLint/Utilities/Formatters/CodeFormatter.swift
  • DevLint/DevLint/Components/CodeEditorView.swift
  • DevLint/DevLintTests/TokenizerTests.swift
  • DevLint/DevLint.xcodeproj/project.pbxproj

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@DevLint/DevLint/Components/CodeEditorView.swift`:
- Around line 120-126: In updateThemeIfNeeded(for:) replace the hardcoded
NSFont.monospacedSystemFont(ofSize:14, weight:.regular) with the theme's
configured font so the editor stays in sync with ThemeManager; use
themeManager.currentTheme.font (with a safe fallback to a sensible default font
if that property is nil) to set textView.font, leaving the backgroundColor,
textColor and insertionPointColor assignments unchanged.

In `@DevLint/DevLint/Core/ThemeManager.swift`:
- Around line 85-89: The initializer is overwriting persisted theme because
updateThemeForDarkMode() mutates selectedThemeName before setTheme(name:)
restores it, and the toolbar picker binds currentTheme directly so changes never
call setTheme(name:) to persist; fix by moving persistence onto currentTheme
(add a didSet on currentTheme to call setTheme(name:) or persist the
selectedThemeName) so any change to currentTheme is saved, and change
updateThemeForDarkMode() to apply a dark-mode fallback without mutating the
stored selectedThemeName (only adjust currentTheme for UI presentation). Also
update CustomToolbar to bind the picker to currentTheme as before but rely on
currentTheme's didSet to persist rather than calling setTheme from the view.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8dbd90e5-e374-42a7-ac63-aa124bb43175

📥 Commits

Reviewing files that changed from the base of the PR and between 408cd91 and 23c575b.

📒 Files selected for processing (4)
  • DevLint/DevLint/Components/CodeEditorView.swift
  • DevLint/DevLint/Core/ThemeManager.swift
  • DevLint/DevLint/Utilities/Formatters/CodeFormatter.swift
  • DevLint/DevLint/ViewModels/CodeEditorViewModel.swift

Comment on lines +120 to +126
/// Updates the given text view's colors and font when its background color differs from the current theme.
/// - Parameter textView: The `NSTextView` whose background color, text color, insertion point color, and font will be synchronized to the current theme if they are out of date.
private func updateThemeIfNeeded(for textView: NSTextView) {
textView.backgroundColor = themeManager.currentTheme.backgroundColor
textView.textColor = themeManager.currentTheme.primaryColor
textView.insertionPointColor = themeManager.currentTheme.primaryColor
textView.font = NSFont.monospacedSystemFont(ofSize: 14, weight: .regular)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use the theme font here instead of hardcoding 14pt.

Line 126 ignores themeManager.currentTheme.font, so this method does not actually keep the editor font in sync with the active theme even though ThemeManager.swift stores a font per theme and this method’s contract says it does.

Suggested fix
-        textView.font = NSFont.monospacedSystemFont(ofSize: 14, weight: .regular)
+        textView.font = themeManager.currentTheme.font
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Updates the given text view's colors and font when its background color differs from the current theme.
/// - Parameter textView: The `NSTextView` whose background color, text color, insertion point color, and font will be synchronized to the current theme if they are out of date.
private func updateThemeIfNeeded(for textView: NSTextView) {
textView.backgroundColor = themeManager.currentTheme.backgroundColor
textView.textColor = themeManager.currentTheme.primaryColor
textView.insertionPointColor = themeManager.currentTheme.primaryColor
textView.font = NSFont.monospacedSystemFont(ofSize: 14, weight: .regular)
/// Updates the given text view's colors and font when its background color differs from the current theme.
/// - Parameter textView: The `NSTextView` whose background color, text color, insertion point color, and font will be synchronized to the current theme if they are out of date.
private func updateThemeIfNeeded(for textView: NSTextView) {
textView.backgroundColor = themeManager.currentTheme.backgroundColor
textView.textColor = themeManager.currentTheme.primaryColor
textView.insertionPointColor = themeManager.currentTheme.primaryColor
textView.font = themeManager.currentTheme.font
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DevLint/DevLint/Components/CodeEditorView.swift` around lines 120 - 126, In
updateThemeIfNeeded(for:) replace the hardcoded
NSFont.monospacedSystemFont(ofSize:14, weight:.regular) with the theme's
configured font so the editor stays in sync with ThemeManager; use
themeManager.currentTheme.font (with a safe fallback to a sensible default font
if that property is nil) to set textView.font, leaving the backgroundColor,
textColor and insertionPointColor assignments unchanged.

Comment thread DevLint/DevLint/Core/ThemeManager.swift
@csprasad csprasad merged commit 6e8b1c7 into main Jun 14, 2026
2 checks passed
@csprasad csprasad deleted the patch-1 branch June 14, 2026 12:58
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