Skip to content

Conversation

@akyTheDev
Copy link

@akyTheDev akyTheDev commented Jan 9, 2026

Introduce a new editor option foldingAddNewlineAtEnd that controls whether a newline character is added when folding the last line of a file. This option defaults to true, ensuring that a newline is inserted to maintain a clean separation at the end of the file when the last line is folded.

The implementation includes updates to the folding model to check for this option and conditionally insert a newline. Additionally, tests have been added to verify the behavior of this new feature under various scenarios, including when the option is disabled or when the last line is already empty.

#279302

Copilot AI review requested due to automatic review settings January 9, 2026 21:17
@akyTheDev
Copy link
Author

@microsoft-github-policy-service agree

@microsoft-github-policy-service agree

Copy link
Contributor

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 introduces a new editor option foldingAddNewlineAtEnd that controls whether a newline is automatically inserted when folding the last line of a file. The feature defaults to enabled (true) to maintain clean file separation when the last line is folded.

Changes:

  • Added foldingAddNewlineAtEnd boolean option to editor configuration (defaults to true)
  • Modified folding model to check this option and conditionally insert newline when folding last line
  • Updated all test files to pass editor instance to FoldingModel constructor
  • Added comprehensive test coverage for the new feature

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/vs/editor/common/config/editorOptions.ts Added foldingAddNewlineAtEnd option definition and registration
src/vs/editor/common/standalone/standaloneEnums.ts Updated EditorOption enum to include new option with renumbered subsequent entries
src/vs/editor/contrib/folding/browser/foldingModel.ts Implemented newline insertion logic in toggleCollapseState method, added editor parameter to constructor
src/vs/editor/contrib/folding/browser/folding.ts Updated FoldingModel instantiation to pass editor instance
src/vs/editor/contrib/folding/test/browser/foldingModel.test.ts Added helper function and four new tests for the feature, updated all existing test instantiations
src/vs/editor/contrib/folding/test/browser/hiddenRangeModel.test.ts Added helper function and updated test instantiation to pass editor mock

@akyTheDev akyTheDev force-pushed the akyTheDev/add-new-line-at-end-on-fold branch 2 times, most recently from bc03435 to 2077e3d Compare January 9, 2026 21:35
Introduce a new editor option `foldingAddNewlineAtEnd` that controls whether a newline character is added when folding the last line of a file. This option defaults to true, ensuring that a newline is inserted to maintain a clean separation at the end of the file when the last line is folded.

The implementation includes updates to the folding model to check for this option and conditionally insert a newline. Additionally, tests have been added to verify the behavior of this new feature under various scenarios, including when the option is disabled or when the last line is already empty.
@akyTheDev akyTheDev force-pushed the akyTheDev/add-new-line-at-end-on-fold branch from 2077e3d to 62f7c3d Compare January 9, 2026 21:36
@akyTheDev akyTheDev requested a review from Copilot January 9, 2026 21:37
Copy link
Contributor

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

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

@akyTheDev akyTheDev requested a review from Copilot January 9, 2026 21:48
Copy link
Contributor

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

Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.

@RedCMD
Copy link
Contributor

RedCMD commented Jan 9, 2026

should send screenshot/screen recording

@akyTheDev
Copy link
Author

@RedCMD

Here is the screen recording 🙂

output.mp4

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.

3 participants