Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/extensions/default/CodeFolding/foldhelpers/foldcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ define(function (require, exports, module) {
});

textRange.on("clear", function (from, to) {
delete cm._lineFolds[from.line];
CodeMirror.signal(cm, "unfold", cm, from, to);
delete cm._lineFolds[pos.line];
CodeMirror.signal(cm, "unfold", cm, from, to, pos.line);
});

if (force === "fold") {
Expand All @@ -101,7 +101,7 @@ define(function (require, exports, module) {
delete cm._lineFolds[pos.line];
}

CodeMirror.signal(cm, force, cm, range.from, range.to);
CodeMirror.signal(cm, force, cm, range.from, range.to, pos.line);
return range;
}

Expand Down
19 changes: 15 additions & 4 deletions src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,19 +355,30 @@ define(function (require, exports, module) {
* @param {!CodeMirror} cm the CodeMirror instance for the active editor
* @param {!Object} from the ch and line position that designates the start of the region
* @param {!Object} to the ch and line position that designates the end of the region
* @param {?Number} gutterLineNumber the gutter line number that was clicked to signal the fold event
*/
function onFold(cm, from, to) {
updateFoldInfo(cm, from.line, from.line + 1);
function onFold(cm, from, to, gutterLineNumber) {
var state = cm.state.foldGutter,
line = isNaN(gutterLineNumber) ? from.line : gutterLineNumber;
if (line >= state.from && line < state.to) {
updateFoldInfo(cm, line, line + 1);
}
}

/**
* Triggered when a folded code segment is unfolded.
* @param {!CodeMirror} cm the CodeMirror instance for the active editor
* @param {!{line:number, ch:number}} from the ch and line position that designates the start of the region
* @param {!{line:number, ch:number}} to the ch and line position that designates the end of the region
* @param {?Number} gutterLineNumber the gutter line number that was clicked to signal the fold event
*/
function onUnFold(cm, from, to) {
updateFoldInfo(cm, from.line, from.line + 1);
function onUnFold(cm, from, to, gutterLineNumber) {
var state = cm.state.foldGutter,
line = isNaN(gutterLineNumber) ? from.line : gutterLineNumber;
var vp = cm.getViewport();
if (line >= state.from && line < state.to) {
updateFoldInfo(cm, line, Math.min(vp.to, to.line));
}
}

/**
Expand Down