Skip to content

Conversation

@vksvicky
Copy link
Contributor

@vksvicky vksvicky commented Feb 1, 2026

… 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

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

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

01  Disabled wrapping 02  Enabled 2 spaces 03  Enabled 8 spaces 04  Enabled 20 spaces

… 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
Copy link

Copilot AI left a 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 wrappedLineIndent setting 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.

Comment on lines +64 to 71
/// 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

Copy link

Copilot AI Feb 4, 2026

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.

Suggested change
/// 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

Copilot uses AI. Check for mistakes.
Comment on lines +131 to +134
self.wrappedLineIndent = try container.decodeIfPresent(
Int.self,
forKey: .wrappedLineIndent
) ?? 4
Copy link

Copilot AI Feb 4, 2026

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +54
@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)
}
}
Copy link

Copilot AI Feb 4, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines 77 to +79
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)
Copy link

Copilot AI Feb 4, 2026

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.

Copilot uses AI. Check for mistakes.
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.

2 participants