提交 8a0da20f 编写于 作者: A Alex Dima

Cursor computes pageSize, not configuration

上级 e477f92e
......@@ -81,7 +81,6 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
wrappingInfo: editorCommon.EditorWrappingInfo;
contribInfo: editorCommon.EditorContribOptions;
lineHeight:number;
pageSize:number;
constructor(input:editorCommon.IInternalEditorOptions) {
this.wordSeparators = String(input.wordSeparators);
......@@ -100,7 +99,6 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
this.wrappingInfo = input.wrappingInfo.clone();
this.contribInfo = input.contribInfo.clone();
this.lineHeight = Number(input.lineHeight)|0;
this.pageSize = Number(input.pageSize)|0;
}
}
......@@ -164,8 +162,6 @@ class InternalEditorOptionsHelper {
verticalScrollbarHasArrows: scrollbar.verticalHasArrows
});
let pageSize = Math.floor(layoutInfo.height / fontInfo.lineHeight) - 2;
if (isDominatedByLongLines && wrappingColumn > 0) {
// Force viewport width wrapping if model is dominated by long lines
wrappingColumn = 0;
......@@ -264,7 +260,6 @@ class InternalEditorOptionsHelper {
contribInfo: contribInfo,
lineHeight: fontInfo.lineHeight, // todo -> duplicated in styling
pageSize: pageSize,
};
}
......@@ -325,7 +320,6 @@ class InternalEditorOptionsHelper {
wrappingInfo: (!prevOpts.wrappingInfo.equals(newOpts.wrappingInfo)),
contribInfo: (!prevOpts.contribInfo.equals(newOpts.contribInfo)),
lineHeight: (prevOpts.lineHeight !== newOpts.lineHeight),
pageSize: (prevOpts.pageSize !== newOpts.pageSize),
};
}
}
......
......@@ -66,7 +66,7 @@ interface ICommandsData {
export class Cursor extends EventEmitter {
private editorId:number;
/*private*/ configuration:editorCommon.IConfiguration;
private configuration:editorCommon.IConfiguration;
private model:editorCommon.IModel;
private modelUnbinds:IDisposable[];
......@@ -1288,11 +1288,11 @@ export class Cursor extends EventEmitter {
}
private _moveDown(inSelectionMode:boolean, isPaged:boolean, ctx: IMultipleCursorOperationContext): boolean {
return this._invokeForAll(ctx, (cursorIndex: number, oneCursor: OneCursor, oneCtx: IOneCursorOperationContext) => OneCursorOp.moveDown(oneCursor, inSelectionMode, isPaged, oneCtx));
return this._invokeForAll(ctx, (cursorIndex: number, oneCursor: OneCursor, oneCtx: IOneCursorOperationContext) => OneCursorOp.moveDown(oneCursor, inSelectionMode, isPaged, ctx.eventData && ctx.eventData.pageSize || 0, oneCtx));
}
private _moveUp(inSelectionMode:boolean, isPaged:boolean, ctx: IMultipleCursorOperationContext): boolean {
return this._invokeForAll(ctx, (cursorIndex: number, oneCursor: OneCursor, oneCtx: IOneCursorOperationContext) => OneCursorOp.moveUp(oneCursor, inSelectionMode, isPaged, oneCtx));
return this._invokeForAll(ctx, (cursorIndex: number, oneCursor: OneCursor, oneCtx: IOneCursorOperationContext) => OneCursorOp.moveUp(oneCursor, inSelectionMode, isPaged, ctx.eventData && ctx.eventData.pageSize || 0, oneCtx));
}
private _moveToBeginningOfLine(inSelectionMode:boolean, ctx: IMultipleCursorOperationContext): boolean {
......@@ -1451,12 +1451,12 @@ export class Cursor extends EventEmitter {
}
private _scrollUp(isPaged: boolean, ctx: IMultipleCursorOperationContext): boolean {
ctx.requestScrollDeltaLines = isPaged ? -this.configuration.editor.pageSize : -1;
ctx.requestScrollDeltaLines = isPaged ? -this.cursors.getAll()[0].getPageSize() : -1;
return true;
}
private _scrollDown(isPaged: boolean, ctx: IMultipleCursorOperationContext): boolean {
ctx.requestScrollDeltaLines = isPaged ? this.configuration.editor.pageSize : 1;
ctx.requestScrollDeltaLines = isPaged ? this.cursors.getAll()[0].getPageSize() : 1;
return true;
}
......
......@@ -450,6 +450,11 @@ export class OneCursor {
// -------------------- START reading API
public getPageSize(): number {
let c = this.configuration.editor;
return Math.floor(c.layoutInfo.height / c.fontInfo.lineHeight) - 2;
}
public getSelectionStart(): editorCommon.IEditorRange {
return this.selectionStart;
}
......@@ -675,7 +680,7 @@ export class OneCursorOp {
}
public static columnSelectUp(isPaged:boolean, cursor:OneCursor, toViewLineNumber: number, toViewVisualColumn: number): IColumnSelectResult {
var linesCount = isPaged ? cursor.configuration.editor.pageSize : 1;
var linesCount = isPaged ? cursor.getPageSize() : 1;
toViewLineNumber -= linesCount;
if (toViewLineNumber < 1) {
......@@ -686,7 +691,7 @@ export class OneCursorOp {
}
public static columnSelectDown(isPaged:boolean, cursor:OneCursor, toViewLineNumber: number, toViewVisualColumn: number): IColumnSelectResult {
var linesCount = isPaged ? cursor.configuration.editor.pageSize : 1;
var linesCount = isPaged ? cursor.getPageSize() : 1;
toViewLineNumber += linesCount;
if (toViewLineNumber > cursor.getViewLineCount()) {
......@@ -812,8 +817,8 @@ export class OneCursorOp {
return true;
}
public static moveDown(cursor:OneCursor, inSelectionMode: boolean, isPaged: boolean, ctx: IOneCursorOperationContext): boolean {
var linesCount = isPaged ? cursor.configuration.editor.pageSize : 1;
public static moveDown(cursor:OneCursor, inSelectionMode: boolean, isPaged: boolean, usePageSize: number, ctx: IOneCursorOperationContext): boolean {
var linesCount = isPaged ? (usePageSize || cursor.getPageSize()) : 1;
var viewLineNumber:number,
viewColumn:number;
......@@ -853,8 +858,8 @@ export class OneCursorOp {
return true;
}
public static moveUp(cursor:OneCursor, inSelectionMode: boolean, isPaged: boolean, ctx: IOneCursorOperationContext): boolean {
var linesCount = isPaged ? cursor.configuration.editor.pageSize : 1;
public static moveUp(cursor:OneCursor, inSelectionMode: boolean, isPaged: boolean, usePageSize: number, ctx: IOneCursorOperationContext): boolean {
var linesCount = isPaged ? (usePageSize || cursor.getPageSize()) : 1;
var viewLineNumber:number,
viewColumn:number;
......
......@@ -903,7 +903,6 @@ export interface IInternalEditorOptions {
wordSeparators: string;
autoClosingBrackets:boolean;
useTabStops: boolean;
pageSize:number;
tabFocusMode:boolean;
// ---- model options
......@@ -955,7 +954,6 @@ export interface IConfigurationChangedEvent {
wrappingInfo: boolean;
contribInfo: boolean;
lineHeight: boolean;
pageSize: boolean;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册