-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Indent wrapped lines (CodeEditTextView #18): settings, UI, tests; git… #2158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… tests; git status skip unknown types; lint fixes - Add wrappedLineIndent setting and UI in Text Editing preferences - Add TextEditingSettingsTests for wrapped line indent - GitClient+Status: skip unknown porcelain v2 entry types instead of throwing - Lint: shorten doc comment, strip trailing whitespace in WorkspaceView - CodeFileView: pass wrappedLineIndent when using local CodeEditSourceEditor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for indenting wrapped lines in the code editor, exposing a new user preference that allows customization of continuation line indentation (e.g., 4 or 12 spaces, like Xcode). The PR also includes a bug fix for Git status parsing and minor lint cleanup.
Changes:
- Added
wrappedLineIndentsetting with default value of 4 spaces, configurable via UI stepper (range 0-24) - Added comprehensive test coverage for the new wrapped line indent setting
- Changed Git status parser to skip unknown porcelain v2 entry types instead of throwing errors, improving forward compatibility
- Removed trailing whitespace in WorkspaceView.swift
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| CodeEditTests/Features/Settings/TextEditingSettingsTests.swift | New test file with comprehensive tests for wrapped line indent feature including default values, Codable round-tripping, and valid range |
| CodeEdit/WorkspaceView.swift | Removed trailing whitespace on line 89 (lint fix) |
| CodeEdit/Features/SourceControl/Client/GitClient+Status.swift | Changed default case to skip unknown entry types instead of throwing error, improving forward compatibility with future Git versions |
| CodeEdit/Features/Settings/Pages/TextEditingSettings/TextEditingSettingsView.swift | Added UI stepper control for wrapped line indent setting with range 0-24, disabled when line wrapping is off |
| CodeEdit/Features/Settings/Pages/TextEditingSettings/Models/TextEditingSettings.swift | Added wrappedLineIndent property with default of 4, added to searchKeys, implemented decoder with default value handling |
| CodeEdit/Features/Editor/Views/CodeFileView.swift | Added binding for wrappedLineIndent setting and passed it to SourceEditorConfiguration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// Spaces to indent continuation lines when line wrapping | ||
| /// is on (e.g. 4 or 12). See: | ||
| /// https://github.com/CodeEditApp/CodeEditTextView/issues/18 | ||
| var wrappedLineIndent: Int = 4 | ||
|
|
||
| /// The percentage of overscroll to apply to the text view | ||
| var overscroll: OverscrollOption = .medium | ||
|
|
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation comment spans multiple lines but doesn't follow the standard Swift documentation format. In the codebase, similar properties use single-line comments (see lines 45-46, 52-53, 55-56, 58-59, 61-62, 69-70). Consider condensing to a single-line comment for consistency, or if the reference is important, format it as a proper multi-line doc comment with proper indentation on continuation lines.
| /// Spaces to indent continuation lines when line wrapping | |
| /// is on (e.g. 4 or 12). See: | |
| /// https://github.com/CodeEditApp/CodeEditTextView/issues/18 | |
| var wrappedLineIndent: Int = 4 | |
| /// The percentage of overscroll to apply to the text view | |
| var overscroll: OverscrollOption = .medium | |
| /// Spaces to indent continuation lines when line wrapping is on (e.g. 4 or 12); see https://github.com/CodeEditApp/CodeEditTextView/issues/18 | |
| var wrappedLineIndent: Int = 4 | |
| /// The percentage of overscroll to apply to the text view | |
| var overscroll: OverscrollOption = .medium | |
| var overscroll: OverscrollOption = .medium |
| self.wrappedLineIndent = try container.decodeIfPresent( | ||
| Int.self, | ||
| forKey: .wrappedLineIndent | ||
| ) ?? 4 |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no validation to clamp values outside the expected range (0-24) when decoding from JSON or when the property is set programmatically. While the UI Stepper enforces this range, values set directly (e.g., via JSON manipulation or programmatic access) could be invalid. Consider adding validation in the decoder or using a property wrapper with a didSet observer to clamp values to the valid range, similar to how other settings with constraints are handled elsewhere in the codebase.
| self.wrappedLineIndent = try container.decodeIfPresent( | |
| Int.self, | |
| forKey: .wrappedLineIndent | |
| ) ?? 4 | |
| let decodedWrappedLineIndent = try container.decodeIfPresent( | |
| Int.self, | |
| forKey: .wrappedLineIndent | |
| ) ?? 4 | |
| self.wrappedLineIndent = min(max(decodedWrappedLineIndent, 0), 24) |
| @Test("Wrapped line indent accepts valid range 0–24") | ||
| func wrappedLineIndentValidRange() throws { | ||
| for value in [0, 4, 8, 12, 24] { | ||
| var settings = SettingsData.TextEditingSettings() | ||
| settings.wrappedLineIndent = value | ||
| let encoded = try JSONEncoder().encode(settings) | ||
| let decoded = try JSONDecoder().decode(SettingsData.TextEditingSettings.self, from: encoded) | ||
| #expect(decoded.wrappedLineIndent == value) | ||
| } | ||
| } |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests validate the range 0-24, but they don't test boundary violations or what happens when invalid values (e.g., -1, 25, 100) are set directly on the property or decoded from JSON. Consider adding tests for these edge cases to ensure the setting handles invalid values gracefully, especially since there's no validation logic in the model to prevent out-of-range values.
| default: | ||
| throw GitClientError.statusInvalidChangeType(output[typeIndex]) | ||
| // Skip unknown entry types (e.g. future porcelain v2 types or unexpected output) | ||
| try substringToNextNull(from: &index, output: output) |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the change from throwing to silently skipping unknown entry types is reasonable for forward compatibility, there's no test coverage for this behavior. Consider adding a test case that includes an unknown entry type character in the status output to verify that it's properly skipped without affecting the parsing of other entries. This would help prevent regressions and document the expected behavior.
… status skip unknown types; lint fixes
Description
Adds support for indent wrapped lines (CodeEditTextView #18) from the CodeEdit side: a new preference and UI so users can choose how many spaces to indent continuation lines when line wrapping is on (e.g. 4 or 12, like Xcode).
The actual wrapping/indent behaviour is implemented in CodeEditTextView/CodeEditSourceEditor; this PR adds the setting and wires it through when those packages expose the API.
Related Issues
Addresses CodeEditTextView #18 (Indent wrapped lines) from the CodeEdit app side (settings + UI). The underlying feature is implemented in CodeEditTextView and CodeEditSourceEditor; this PR adds the preference and passes it through.
Checklist
Screenshots