Add autocompleteBraces behavior setting#363
Add autocompleteBraces behavior setting#363William-Laverty wants to merge 1 commit intoCodeEditApp:mainfrom
Conversation
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
There was a problem hiding this comment.
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
autocompleteBracesboolean property toBehaviorstruct with default valuetruefor 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
autocompleteBraceschanges
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 |
There was a problem hiding this comment.
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:
- When
autocompleteBracesistrue, typing an opening bracket automatically inserts the closing bracket - When
autocompleteBracesisfalse, typing an opening bracket does not insert the closing bracket - Changing the setting from
truetofalseproperly removes the bracket pair filters - 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.
Summary
Adds a new
autocompleteBracesoption to theBehaviorconfiguration 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
autocompleteBracesproperty toBehaviorstruct (default:truefor backward compatibility)OpenPairFilterandDeletePairFilterbased on settingsetUpTextFormation()when setting changesUsage in CodeEdit
After this PR is merged, CodeEdit can pass the user's preference:
Testing
autocompleteBraces: true(default){→ Should auto-insert}autocompleteBraces: false{→ Should only insert{Related