Skip to content

Commit

Permalink
fixes microsoft#3314: [folding] File contents scrolls if folding is t…
Browse files Browse the repository at this point in the history
…urned off
  • Loading branch information
aeschli committed Feb 25, 2016
1 parent feb540e commit a87b674
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/vs/editor/contrib/folding/browser/folding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import {INullService} from 'vs/platform/instantiation/common/instantiation';
import {EditorAction} from 'vs/editor/common/editorAction';
import * as editorCommon from 'vs/editor/common/editorCommon';
import {Range} from 'vs/editor/common/core/range';
import {CommonEditorRegistry, ContextKey, EditorActionDescriptor} from 'vs/editor/common/editorCommonExtensions';
import {ICodeEditor, IEditorMouseEvent} from 'vs/editor/browser/editorBrowser';
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
Expand Down Expand Up @@ -371,6 +372,8 @@ export class FoldingController implements editorCommon.IEditorContribution {

private updateHiddenAreas(): void {
let model = this.editor.getModel();
var cursorPosition : editorCommon.IPosition = this.editor.getPosition();
var updateCursorPosition = false;
let hiddenAreas: editorCommon.IRange[] = [];
this.decorations.filter(dec => dec.isCollapsed).forEach(dec => {
let decRange = dec.getDecorationRange(model);
Expand All @@ -380,8 +383,16 @@ export class FoldingController implements editorCommon.IEditorContribution {
endLineNumber: decRange.endLineNumber,
endColumn: 1
});
if (Range.containsPosition(decRange, cursorPosition)) {
cursorPosition = { lineNumber: decRange.startLineNumber, column: model.getLineMaxColumn(decRange.startLineNumber) };
updateCursorPosition = true;
}
});
if (updateCursorPosition) {
this.editor.setPosition(cursorPosition);
}
this.editor.setHiddenAreas(hiddenAreas);
this.editor.revealPositionInCenterIfOutsideViewport(cursorPosition);
}

private findRegions(lineNumber: number, collapsed: boolean): CollapsibleRegion[] {
Expand Down

0 comments on commit a87b674

Please sign in to comment.