-
-
Couldn't load subscription status.
- Fork 3.1k
Code folding #14593
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
Open
DubrovinEIu
wants to merge
17
commits into
helix-editor:master
Choose a base branch
from
DubrovinEIu:code-folding
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Code folding #14593
+7,115
−401
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added the new method `update_positions_with_helper` for `ChangeSet` Added the new module `text_folding::transaction`
Created RopeSlice extension RopeSliceFoldExt Created functions nth_prev_folded_grapheme_boundary, nth_next_folded_grapheme_boundary
Modified movement functions:
move_horizontally
move_vertically
move_vertically_visual
word_move
move_paragraph
Added fold decoration to display folded lines. Embedded fold updating and removal when applying a transaction and selection movement.
Needed to fold comments.
Replaced CharMatcher with GraphemeMatcher. Therefore the line ending search utilizes the regular function of char searching. The function "find_char_line_ending" has been removed.
commands list:
extend_line
extend_line_above
extend_line_below
open_below
goto_last_line
extend_to_last_line
paste_after
A new attribute has appeared - "fold_textobjects". It determines which text objects will be folded when a document is opened. When a split occurs, the folds are copied.
|
would it make sense to add toggle-fold command too? |
|
Added the command |
|
Would it not be better to bind only the toggle command to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Related to #1840
Screencast.From.2025-10-13.16-37-20.mp4
New user-level items
Introduced text folding commands:
fold(default key-mapping iszf)unfold(default key-mapping iszF):fold:unfoldAdded the field
fold_textobjectstoeditor(default list is empty, try to add some of the following available textobjects: class, function, comment)Added the style
ui.virtual.fold-decorationCommands that ignore folded text
The following commands behave as if there is no folded text.
Move word:
move_next_word_startmove_prev_word_startmove_prev_word_endmove_next_word_endmove_next_long_word_startmove_prev_long_word_startmove_prev_long_word_endmove_next_long_word_endmove_next_sub_word_startmove_prev_sub_word_startmove_prev_sub_word_endmove_next_sub_word_endExtend word:
extend_next_word_startextend_prev_word_startextend_next_word_endextend_prev_word_endextend_next_long_word_startextend_prev_long_word_startextend_prev_long_word_endextend_next_long_word_endextend_next_sub_word_startextend_prev_sub_word_startextend_prev_sub_word_endextend_next_sub_word_endMove paragraph:
goto_prev_paragraphgoto_next_paragraphFind char:
find_till_charfind_next_charextend_till_charextend_next_chartill_prev_charfind_prev_charextend_till_prev_charextend_prev_charExtend line:
extend_lineextend_line_aboveextend_line_belowOpen:
open_belowTo last line:
goto_last_lineextend_to_last_linePaste:
paste_afterGoto TS object:
NOTE: the commands skip only entire folded TS objects
goto_next_functiongoto_prev_functiongoto_next_classgoto_prev_classgoto_next_parametergoto_prev_parametergoto_next_commentgoto_prev_commentgoto_next_testgoto_prev_testgoto_next_xml_elementgoto_prev_xml_elementgoto_next_entrygoto_prev_entryTo word:
goto_wordextend_to_wordActions that create folds
Split:
NOTE: commands copy folds to the new view
hsplitvsplit:hsplit:vsplitFile:
NOTE: when a new buffer is opened the specified text objects in the field
fold_textobjectsare folded.file_pickerfile_explorerhx -- src/main.rswill open the file and fold the text objects defined infold_textobjects)Accompanying changes
CharMatcherwithGraphemeMatcher.For more details, check the commit f320270.
TextObjectQuery::capture_nodes_any(issue "Match around comment" not selecting full commented block made of line comments #11087)Also, the fix was pushed as PR Fixed matching around comment #14591.
Speech
Fold primitives have been implemented, including all components related to rendering and text processing.
However, user-items are currently in draft form. Perhaps someone could suggest more convenient commands. Therefore, the documentation has not yet been written.
I suggest applying this PR in order for master-users to test the new feature and open an issue related to text folding.
Check the commit history for details. I have been trying to make it readable, consistent, and organized.
Start by reading the top-level documentation of the
text_foldingmodule.Planned improvements
Enable language-specific text folding.