提交 8a9068fd 编写于 作者: D Don Williamson

Add Output Panel Smart Scroll. Output panel stops scrolling when clicked upon...

Add Output Panel Smart Scroll. Output panel stops scrolling when clicked upon to place the primary cursor. Scrolling resumes when the cursor is placed at the end of the output again. Fixes #49110.
上级 aaf7b296
......@@ -12,6 +12,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { Event, Emitter } from 'vs/base/common/event';
import URI from 'vs/base/common/uri';
import { IDisposable, dispose, Disposable, toDisposable } from 'vs/base/common/lifecycle';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { Registry } from 'vs/platform/registry/common/platform';
......@@ -532,6 +533,31 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
}
}
private smartRevealLastLine(outputPanel: OutputPanel) {
const codeEditor = <ICodeEditor>outputPanel.getControl();
const model = codeEditor.getModel();
if (model) {
// Only scroll if the cursor is currently on the last line of the output panel. This allows
// users to click on the output panel to stop scrolling when they see something of interest.
// To resume, they should scroll to the end of the output panel again.
const lastLine = model.getLineCount();
if (codeEditor.getPosition().lineNumber === lastLine) {
codeEditor.revealPosition({ lineNumber: lastLine, column: model.getLineMaxColumn(lastLine) });
}
}
}
private setPrimaryCursorToLastLine(): void {
const codeEditor = <ICodeEditor>this._outputPanel.getControl();
const model = codeEditor.getModel();
if (model) {
const lastLine = model.getLineCount();
codeEditor.setPosition({ lineNumber: lastLine, column: model.getLineMaxColumn(lastLine) });
}
}
private createChannel(id: string): OutputChannel {
const channelDisposables: IDisposable[] = [];
const channel = this.instantiateChannel(id);
......@@ -539,7 +565,8 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
if (!channel.scrollLock) {
const panel = this.panelService.getActivePanel();
if (panel && panel.getId() === OUTPUT_PANEL_ID && this.isChannelShown(channel)) {
(<OutputPanel>panel).revealLastLine();
let outputPanel = <OutputPanel>panel;
this.smartRevealLastLine(outputPanel);
}
}
}, channelDisposables);
......@@ -588,7 +615,9 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
if (!preserveFocus) {
this._outputPanel.focus();
}
});
})
// Activate smart scroll when switching back to the output panel
.then(() => this.setPrimaryCursorToLastLine());
}
return TPromise.as(null);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册