-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Allow code-folding for selected text in editor #11538
Conversation
…folding-unit-tests # By Marcel Gerber (5) and others # Via Arun Bose (2) and others * 'master' of https://github.com/adobe/brackets: Actually pass the right value to substr Update strings.js Correct URL Update Lodash -> 3.10.0 Make use of new Lodash features Adjust code for Lodash 3.x Update Lodash -> 3.6.0
…king that preference values work as expected
…folding-unit-tests # By Marcel Gerber # Via Marcel Gerber (1) and Prashanth Nethi (1) * 'master' of https://github.com/adobe/brackets: Highlight .xsd files as XML
…ected * commit '1e09fb219224cd80137a8bd1f0cb8326c6814010': Highlight .xsd files as XML
@thehogfather Wow! That was quick. Thanks for this PR!. |
@@ -35,7 +36,9 @@ define(function (require, exports, module) { | |||
{name: HIDE_FOLD_BUTTONS, description: Strings.DESCRIPTION_CODE_FOLDING_HIDE_UNTIL_MOUSEOVER}); | |||
prefs.definePreference("maxFoldLevel", "number", 2, | |||
{name: MAX_FOLD_LEVEL, description: Strings.DESCRIPTION_CODE_FOLDING_MAX_FOLD_LEVEL}); | |||
|
|||
prefs.definePreference("makeSelectionsFoldable", "boolean", true, | |||
{name: MAKE_SELECTIONS_FOLDABLE, description: MAKE_SELECTIONS_FOLDABLE}); |
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.
Use Strings.*
instead for the description
so it's translateable.
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.
@marcelgerber sure thing! I shall update.
Thanks @thehogfather for the PR. |
…ections foldable. Minor modification to CodeMirror helper fold.auto - a range is now only returned if the number of lines spanned by the range is at least the minimum fold size set in the prefs. This has implications for global helpers.
BTW this is still a work in progress. Amongst other things, I need to sort out issues around restoring folds based on selections. Shall update in the next few days. Case
|
@thehogfather I have added a review only tag to the title of the PR, please remove it when you feel this pr is ready to be merged! |
@thehogfather I wrestled with a case similar to 2. with my brackets-persistent-history extension, where I wanted to persist the editing history between project changes and outside changes. My original idea was to invalidate the editing history on the changed part by diffing the files (similar to how you could invalidate / uncollapse changed lines) but in the end I went for a simpler solution where I add another history-step to compensate between the state in the cache and the new changes from outside of Brackets. However the case here is slightly different so it's hard to say what the reasonable expectation would be: overall I wouldn't want Brackets to uncollapse any folds unless absolutely necessary (ie. the folded content has been modified in a way that it doesn't exist (start/end has been removed/modified) anymore), but then again how would you notice that something has changed inside a collapsed fold? One idea would be showing the change in the collapse marker but that's kinda out there too. |
function that updates foldcache now also accounts for selection folds
@petetnt quite! For now I've kept it simple. Selection folds will be restored if and only if they exist in the saved fold preferences and are reported as selection by the ViewStateManager. It might be worth thinking about rendering selection folds ever-so-slightly differently from other types of folds in the gutter. |
…folding-unit-tests
* fold-selected: fix for the creation of multiple fold range widgets for a single collapsed region. updated logic for restoring line folds to account for selection folds function that updates foldcache now also accounts for selection folds Added nls Strings description for code-folding feature for making selections foldable. Minor modification to CodeMirror helper fold.auto - a range is now only returned if the number of lines spanned by the range is at least the minimum fold size set in the prefs. This has implications for global helpers. Added feature to enable code folding for arbitrary selections in the brackets editor
* code-folding-unit-tests: documented and refactored restoreLineFolds function added test for clearing correctness of clearing fold marks in editor added test cases including enabling and disabling extension, and checking that preference values work as expected Basic unit tests for code-folding extension
This reverts commit eb419aa.
@abose I think this is ready to merge. |
@abose I think we should target this for 1.5 |
Allow code-folding for selected text in editor
It working well in all cases i tested. External modification is always a grey area, But no data is getting corrupted / opening up the folds on external modification seeems to be reasonable- which is how it is working now mostly. Thanks for this feature @thehogfather 👍 |
Im really happy about this new feature in version 1.5. If i restart my brackets, my html files are folded out and i have to manually fold in the stuff i dont want to see again. Greetings Maetzzen |
My bracket runs on Windows 8.0 |
Thanks @thehogfather It's Monokai dark soda. |
@Maetzzen can you confirm if there is any difference if you select a different file in your workspace before closing brackets. So fold some regions in your html file as you did before then switch to a different file and then close and reopen brackets. Now check if the folds in your html file are restored or not. |
@thehogfather |
Yeah I understand. But I have a theory about why you are experiencing the issue. To disprove or support my theory your project needs to have multiple files. And you need to change the active editor after you've folded a code region. Hence why I asked that you select a different file (before closing brackets and after folding some regions in an intended file). I could reproduce the issue only if I opened brackets, worked on only a single file and then closed brackets. Hope you understand what I'm trying to say. |
@ezequias' issue is reported here: rainje/Monokai-Dark-Soda/issues/6, there's a suggested workaround mentioned too. |
Thanks @petetnt but I didn't find the monokai main.css but only monokai.css and it does not have the mentioned text. |
@ezequias Did you update the theme to 1.0.9 ? It should be fixed. Tell me if it isn't. |
@rainje yes. Now looks better but I would use a minus sign with the same color of the plus sign to make it perfect. Anyway now is way better than before. Thanks for caring about me. |
@thehogfather for later verisons please consider a "fold all other" / "focus mode" option , it's great when writing blogs or similar stuff |
This is a small addition to the code folding extension that makes any selected text in the editor foldable (provided the number of lines selected is more than the minimum fold size set in the preference).
The feature can be enabled by setting the preference value
"code-folding.makeSelectionFoldable": true
cc @abose