Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ extension TextViewController {

// Filters

setUpOpenPairFilters(pairs: BracketPairs.allValues)
// Only set up bracket pair completion if enabled in settings
if configuration.behavior.autocompleteBraces {
setUpOpenPairFilters(pairs: BracketPairs.allValues)
setUpDeletePairFilters(pairs: BracketPairs.allValues)
}

setUpTagFilter()
setUpNewlineTabFilters(indentOption: configuration.behavior.indentOption)
setUpDeletePairFilters(pairs: BracketPairs.allValues)
setUpDeleteWhitespaceFilter(indentOption: configuration.behavior.indentOption)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@ extension SourceEditorConfiguration {
/// The column to reformat at.
public var reformatAtColumn: Int = 80

/// Controls whether opening brackets automatically insert their closing pair.
/// When true, typing `{` will automatically insert `}` and position the cursor between them.
public var autocompleteBraces: Bool = true
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

The new autocompleteBraces configuration setting lacks test coverage. While the test suite includes comprehensive tests for other behavior configuration options (like indentOption in test_indentBehavior), there are no tests verifying that:

  1. When autocompleteBraces is true, typing an opening bracket automatically inserts the closing bracket
  2. When autocompleteBraces is false, typing an opening bracket does not insert the closing bracket
  3. Changing the setting from true to false properly removes the bracket pair filters
  4. The delete pair behavior is properly controlled by this setting

Consider adding tests similar to the existing test_indentBehavior pattern that verify the bracket autocompletion behavior works correctly in both enabled and disabled states.

Copilot uses AI. Check for mistakes.

public init(
isEditable: Bool = true,
isSelectable: Bool = true,
indentOption: IndentOption = .spaces(count: 4),
reformatAtColumn: Int = 80
reformatAtColumn: Int = 80,
autocompleteBraces: Bool = true
) {
self.isEditable = isEditable
self.isSelectable = isSelectable
self.indentOption = indentOption
self.reformatAtColumn = reformatAtColumn
self.autocompleteBraces = autocompleteBraces
}

@MainActor
Expand All @@ -48,7 +54,7 @@ extension SourceEditorConfiguration {
controller.textView.isSelectable = isSelectable
}

if oldConfig?.indentOption != indentOption {
if oldConfig?.indentOption != indentOption || oldConfig?.autocompleteBraces != autocompleteBraces {
controller.setUpTextFormation()
}

Expand Down