This repository was archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Addresses #12456 #12521
Merged
Merged
Addresses #12456 #12521
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
77e6343
Addresses #12456 where code folding triangles in the gutter were not …
thehogfather 8f28182
removed unused parameters from onFold and onUnfold functions
thehogfather e1ceedf
added html test file and restructured unit test to easily work with a…
thehogfather 5dd3918
Merge branch 'Code-folding-issue-12456' of https://github.com/thehogf…
thehogfather fb7b4a1
cleaned up tests.
thehogfather 78b0612
Merge branch 'master' of https://github.com/adobe/brackets into Code-…
thehogfather af7906f
Addressed CR comments and merged with master.
thehogfather 07fca23
Addresses failing tests
thehogfather 41f6d66
Merge branch 'master' of https://github.com/adobe/brackets into Code-…
thehogfather File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
38 changes: 38 additions & 0 deletions
38
src/extensions/default/CodeFolding/unittest-files/test.html
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <html> | ||
| <head> | ||
|
|
||
| </head> | ||
| <body> | ||
|
|
||
| <form action="#" method="post"> | ||
| <div> | ||
| <label for="name">Text Input:</label> | ||
| <input type="text" name="name" id="name" value="" tabindex="1" /> | ||
| </div> | ||
| <table> | ||
| <thead> | ||
| <tr> | ||
| <th></th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <tr> | ||
| <td></td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
| <div> | ||
| <h4>Radio Button Choice</h4> | ||
|
|
||
| <label | ||
| for="radio-choice-1"> | ||
| Choice 1 | ||
| </label> | ||
| <input type="radio" name="radio-choice-1" id="radio-choice-1" tabindex="2" value="choice-1" /> | ||
|
|
||
| <label for="radio-choice-2">Choice 2</label> | ||
| <input type="radio" name="radio-choice-2" id="radio-choice-2" tabindex="3" value="choice-2" /> | ||
| </div> | ||
| </form> | ||
| </body> | ||
| </html> |
59 changes: 31 additions & 28 deletions
59
src/extensions/default/CodeFolding/unittest-files/test.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,36 @@ | ||
| /** | ||
| * Synchronises the code folding states in the CM doc to cm._lineFolds cache. | ||
| * When an undo operation is done, if folded code fragments are restored, then | ||
| * we need to update cm._lineFolds with the fragments | ||
| * @param {Object} cm cm the CodeMirror instance for the active editor | ||
| * @param {Object} from starting position in the doc to sync the fold states from | ||
| * @param {[[Type]]} lineAdded a number to show how many lines where added to the document | ||
| */ | ||
| function syncDocToFoldsCache(cm, from, lineAdded) { | ||
| var minFoldSize = prefs.getSetting("minFoldSize") || 2; | ||
| var opts = cm.state.foldGutter.options || {}; | ||
| var rf = opts.rangeFinder || CodeMirror.fold.auto; | ||
| var i, pos, folds, fold, range; | ||
| if (lineAdded <= 0) { | ||
| return; | ||
| } | ||
| * Synchronises the code folding states in the CM doc to cm._lineFolds cache. | ||
| * When an undo operation is done, if folded code fragments are restored, then | ||
| * we need to update cm._lineFolds with the fragments | ||
| * @param {Object} cm cm the CodeMirror instance for the active editor | ||
| * @param {Object} from starting position in the doc to sync the fold states from | ||
| * @param {[[Type]]} lineAdded a number to show how many lines where added to the document | ||
| */ | ||
| /*global define, brackets, document, window, $, CodeMirror, isFold, prefs*/ | ||
|
|
||
| function syncDocToFoldsCache(cm, from, lineAdded) { | ||
| "use strict"; | ||
| var minFoldSize = prefs.getSetting("minFoldSize") || 2; | ||
| var opts = cm.state.foldGutter.options || {}; | ||
| var rf = opts.rangeFinder || CodeMirror.fold.auto; | ||
| var i, pos, folds, fold, range; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Brackets style is to use a combined
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, I dont think this file should conform to the brackets style - they are test files and should be able to accommodate plausible scenarios that might appear in projects of anyone using brackets regardless of style. |
||
| if (lineAdded <= 0) { | ||
| return; | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you put this directly aftrer |
||
|
|
||
| for (i = from; i <= from + lineAdded; i = i + 1) { | ||
| pos = CodeMirror.Pos(i); | ||
| folds = cm.doc.findMarksAt(pos).filter(isFold); | ||
| fold = folds.length ? fold = folds[0] : undefined; | ||
| if (fold) { | ||
| range = rf(cm, CodeMirror.Pos(i)); | ||
| if (range && range.to.line - range.from.line >= minFoldSize) { | ||
| cm._lineFolds[i] = range; | ||
| i = range.to.line; | ||
| } else { | ||
| delete cm._lineFolds[i]; | ||
| } | ||
| for (i = from; i <= from + lineAdded; i = i + 1) { | ||
| pos = CodeMirror.Pos(i); | ||
| folds = cm.doc.findMarksAt(pos).filter(isFold); | ||
| fold = folds.length ? fold = folds[0] : undefined; | ||
| if (fold) { | ||
| range = rf(cm, CodeMirror.Pos(i)); | ||
| if (range && range.to.line - range.from.line >= minFoldSize) { | ||
| cm._lineFolds[i] = range; | ||
| i = range.to.line; | ||
| } else { | ||
| delete cm._lineFolds[i]; | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
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.
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.
Put this as the first line followed by an empty line.
I think you can remove some of this too.
isFoldandprefscannot be required?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.
Similar to the html, this is a test file loaded up during the unit tests. the
isFoldandprefsare just there to silence jshint errors.