-
Notifications
You must be signed in to change notification settings - Fork 37.3k
feat(editor): add option to insert newline when folding last line #286834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(editor): add option to insert newline when folding last line #286834
Conversation
@microsoft-github-policy-service agree |
There was a problem hiding this 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
foldingAddNewlineAtEndboolean 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 |
src/vs/editor/contrib/folding/test/browser/foldingModel.test.ts
Outdated
Show resolved
Hide resolved
src/vs/editor/contrib/folding/test/browser/hiddenRangeModel.test.ts
Outdated
Show resolved
Hide resolved
bc03435 to
2077e3d
Compare
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.
2077e3d to
62f7c3d
Compare
There was a problem hiding this 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.
There was a problem hiding this 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.
|
should send screenshot/screen recording |
|
Here is the screen recording 🙂 output.mp4 |
Introduce a new editor option
foldingAddNewlineAtEndthat 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