Skip to content

Conversation

@William-Laverty
Copy link

Summary

Adds a new autocompleteBraces option to the Behavior configuration that controls whether opening brackets automatically insert their closing pair.

This change enables downstream editors like CodeEdit to respect user preferences for bracket auto-completion (addresses CodeEdit issue #1691).

Changes

  • Add autocompleteBraces property to Behavior struct (default: true for backward compatibility)
  • Conditionally set up OpenPairFilter and DeletePairFilter based on setting
  • Trigger setUpTextFormation() when setting changes

Usage in CodeEdit

After this PR is merged, CodeEdit can pass the user's preference:

SourceEditor(
    configuration: SourceEditorConfiguration(
        behavior: .init(
            // ...
            autocompleteBraces: Settings[\.textEditing].autocompleteBraces
        )
    )
)

Testing

  1. Create a SourceEditor with autocompleteBraces: true (default)
  2. Type { → Should auto-insert }
  3. Change to autocompleteBraces: false
  4. Type { → Should only insert {
  5. Backspace should not delete pairs when disabled

Related

  • CodeEdit #1691 (Autocomplete Braces setting is completely non-functional)

Adds a new 'autocompleteBraces' option to the Behavior configuration that
controls whether opening brackets automatically insert their closing pair.

When disabled, typing '{' will only insert '{' without the automatic '}'.

This enables downstream editors like CodeEdit to respect user preferences
for bracket auto-completion.

Changes:
- Add autocompleteBraces property to Behavior struct (default: true)
- Conditionally set up OpenPairFilter and DeletePairFilter based on setting
- Trigger setUpTextFormation when setting changes
Copy link
Collaborator

@0xWDG 0xWDG left a comment

Choose a reason for hiding this comment

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

LGTM

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 pull request adds a new autocompleteBraces configuration option to the Behavior struct that allows downstream editors like CodeEdit to control whether opening brackets automatically insert their closing pairs. This change addresses CodeEdit issue #1691 where the autocomplete braces setting was non-functional.

Changes:

  • Added autocompleteBraces boolean property to Behavior struct with default value true for backward compatibility
  • Modified setUpTextFormation() to conditionally set up bracket pair filters based on the setting value
  • Updated behavior change detection to trigger text formation reconfiguration when autocompleteBraces changes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Sources/CodeEditSourceEditor/SourceEditorConfiguration/SourceEditorConfiguration+Behavior.swift Adds the autocompleteBraces property with default value, updates initializer, and triggers setUpTextFormation() when the setting changes
Sources/CodeEditSourceEditor/Controller/TextViewController+TextFormation.swift Conditionally sets up OpenPairFilter and DeletePairFilter based on autocompleteBraces setting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


/// 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.
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