提交 73e190e3 编写于 作者: A Alex Dima

Fixes #1448: reveal editor cursor position only if contextmenu is triggered via keyboard

上级 66bb68f5
......@@ -88,7 +88,7 @@ export interface IView extends Lifecycle.IDisposable {
getWhitespaces(): EditorCommon.IEditorWhitespace[];
renderOnce(callback:() => any): any;
render(): void;
render(now:boolean): void;
focus(): void;
isFocused(): boolean;
......@@ -584,6 +584,7 @@ export interface ICodeEditor extends EditorCommon.ICommonCodeEditor {
* Get the view zones.
*/
getWhitespaces(): EditorCommon.IEditorWhitespace[];
/**
* Get the horizontal position (left offset) for the column w.r.t to the beginning of the line.
* This method works only if the line `lineNumber` is currently rendered (in the editor's viewport).
......@@ -591,6 +592,11 @@ export interface ICodeEditor extends EditorCommon.ICommonCodeEditor {
*/
getOffsetForColumn(lineNumber: number, column: number): number;
/**
* Force an editor render now.
*/
render(): void;
/**
* Get the vertical position (top offset) for the line w.r.t. to the first line.
*/
......
......@@ -763,12 +763,15 @@ export class View extends ViewEventHandler implements EditorBrowser.IView, Lifec
});
}
public render(): void {
public render(now:boolean): void {
if (this._isDisposed) {
throw new Error('ViewImpl.render: View is disposed');
}
// Force a render with a layout event
this.layoutProvider.emitLayoutChangedEvent();
if (now) {
this._flushAccumulatedAndRenderNow();
}
}
public renderOnce(callback: () => any): any {
......
......@@ -360,6 +360,13 @@ export class CodeEditorWidget extends CommonCodeEditor implements EditorBrowser.
return this._view.getCodeEditorHelper().getOffsetForColumn(lineNumber, column);
}
public render(): void {
if (!this.hasView) {
return;
}
this._view.render(true);
}
_attachModel(model:EditorCommon.IModel): void {
this._view = null;
......@@ -383,7 +390,7 @@ export class CodeEditorWidget extends CommonCodeEditor implements EditorBrowser.
}
}
this._view.render();
this._view.render(false);
this.hasView = true;
});
}
......
......@@ -113,9 +113,6 @@ class ContextMenuController implements EditorCommon.IEditorContribution {
return;
}
// Ensure selection is visible
this._editor.revealPosition(position);
// Find actions available for menu
var menuActions = this._getMenuActions();
......@@ -182,7 +179,10 @@ class ContextMenuController implements EditorCommon.IEditorContribution {
var menuPosition = forcedPosition;
if (!menuPosition) {
// Ensure selection is visible
this._editor.revealPosition(this._editor.getPosition());
this._editor.render();
var cursorCoords = this._editor.getScrolledVisiblePosition(this._editor.getPosition());
// Translate to absolute editor position
......
......@@ -66,7 +66,7 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
this._editor.layoutContentWidget(this);
// Simply force a synchronous render on the editor
// such that the widget does not really render with left = '0px'
this._editor.getOffsetForColumn(this._showAtPosition.lineNumber, this._showAtPosition.column);
this._editor.render();
}
public hide(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册