Skip to content

Commit

Permalink
Fixes #43208: Add editor.scrollBeyondLastColumn
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Apr 27, 2018
1 parent 930ba05 commit 2032be3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/vs/editor/common/config/commonEditorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_DEFAULTS.viewInfo.scrollBeyondLastLine,
'description': nls.localize('scrollBeyondLastLine', "Controls if the editor will scroll beyond the last line")
},
'editor.scrollBeyondLastColumn': {
'type': 'number',
'default': EDITOR_DEFAULTS.viewInfo.scrollBeyondLastColumn,
'description': nls.localize('scrollBeyondLastColumn', "Controls if the editor will scroll beyond the last column")
},
'editor.smoothScrolling': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.viewInfo.smoothScrolling,
Expand Down
10 changes: 10 additions & 0 deletions src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ export interface IEditorOptions {
* Defaults to true.
*/
scrollBeyondLastLine?: boolean;
/**
* Enable that scrolling can go beyond the last column by a number of columns.
* Defaults to 5.
*/
scrollBeyondLastColumn?: number;
/**
* Enable that the editor animates scrolling to a position.
* Defaults to false.
Expand Down Expand Up @@ -825,6 +830,7 @@ export interface InternalEditorViewOptions {
readonly cursorWidth: number;
readonly hideCursorInOverviewRuler: boolean;
readonly scrollBeyondLastLine: boolean;
readonly scrollBeyondLastColumn: number;
readonly smoothScrolling: boolean;
readonly stopRenderingLineAfter: number;
readonly renderWhitespace: 'none' | 'boundary' | 'all';
Expand Down Expand Up @@ -1105,6 +1111,7 @@ export class InternalEditorOptions {
&& a.cursorWidth === b.cursorWidth
&& a.hideCursorInOverviewRuler === b.hideCursorInOverviewRuler
&& a.scrollBeyondLastLine === b.scrollBeyondLastLine
&& a.scrollBeyondLastColumn === b.scrollBeyondLastColumn
&& a.smoothScrolling === b.smoothScrolling
&& a.stopRenderingLineAfter === b.stopRenderingLineAfter
&& a.renderWhitespace === b.renderWhitespace
Expand Down Expand Up @@ -1718,6 +1725,7 @@ export class EditorOptionsValidator {
cursorWidth: _clampedInt(opts.cursorWidth, defaults.cursorWidth, 0, Number.MAX_VALUE),
hideCursorInOverviewRuler: _boolean(opts.hideCursorInOverviewRuler, defaults.hideCursorInOverviewRuler),
scrollBeyondLastLine: _boolean(opts.scrollBeyondLastLine, defaults.scrollBeyondLastLine),
scrollBeyondLastColumn: _clampedInt(opts.scrollBeyondLastColumn, defaults.scrollBeyondLastColumn, 0, Constants.MAX_SAFE_SMALL_INTEGER),
smoothScrolling: _boolean(opts.smoothScrolling, defaults.smoothScrolling),
stopRenderingLineAfter: _clampedInt(opts.stopRenderingLineAfter, defaults.stopRenderingLineAfter, -1, Constants.MAX_SAFE_SMALL_INTEGER),
renderWhitespace: renderWhitespace,
Expand Down Expand Up @@ -1830,6 +1838,7 @@ export class InternalEditorOptionsFactory {
cursorWidth: opts.viewInfo.cursorWidth,
hideCursorInOverviewRuler: opts.viewInfo.hideCursorInOverviewRuler,
scrollBeyondLastLine: opts.viewInfo.scrollBeyondLastLine,
scrollBeyondLastColumn: opts.viewInfo.scrollBeyondLastColumn,
smoothScrolling: opts.viewInfo.smoothScrolling,
stopRenderingLineAfter: opts.viewInfo.stopRenderingLineAfter,
renderWhitespace: (accessibilityIsOn ? 'none' : opts.viewInfo.renderWhitespace), // DISABLED WHEN SCREEN READER IS ATTACHED
Expand Down Expand Up @@ -2280,6 +2289,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
cursorWidth: 0,
hideCursorInOverviewRuler: false,
scrollBeyondLastLine: true,
scrollBeyondLastColumn: 5,
smoothScrolling: false,
stopRenderingLineAfter: 10000,
renderWhitespace: 'none',
Expand Down
5 changes: 2 additions & 3 deletions src/vs/editor/common/viewLayout/viewLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const SMOOTH_SCROLLING_TIME = 125;

export class ViewLayout extends Disposable implements IViewLayout {

static LINES_HORIZONTAL_EXTRA_PX = 30;

private readonly _configuration: editorCommon.IConfiguration;
private readonly _linesLayout: LinesLayout;

Expand Down Expand Up @@ -143,7 +141,8 @@ export class ViewLayout extends Disposable implements IViewLayout {
private _computeScrollWidth(maxLineWidth: number, viewportWidth: number): number {
let isViewportWrapping = this._configuration.editor.wrappingInfo.isViewportWrapping;
if (!isViewportWrapping) {
return Math.max(maxLineWidth + ViewLayout.LINES_HORIZONTAL_EXTRA_PX, viewportWidth);
const extraHorizontalSpace = this._configuration.editor.viewInfo.scrollBeyondLastColumn * this._configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
return Math.max(maxLineWidth + extraHorizontalSpace, viewportWidth);
}
return Math.max(maxLineWidth, viewportWidth);
}
Expand Down
6 changes: 6 additions & 0 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2623,6 +2623,11 @@ declare namespace monaco.editor {
* Defaults to true.
*/
scrollBeyondLastLine?: boolean;
/**
* Enable that scrolling can go beyond the last column by a number of columns.
* Defaults to 5.
*/
scrollBeyondLastColumn?: number;
/**
* Enable that the editor animates scrolling to a position.
* Defaults to false.
Expand Down Expand Up @@ -3088,6 +3093,7 @@ declare namespace monaco.editor {
readonly cursorWidth: number;
readonly hideCursorInOverviewRuler: boolean;
readonly scrollBeyondLastLine: boolean;
readonly scrollBeyondLastColumn: number;
readonly smoothScrolling: boolean;
readonly stopRenderingLineAfter: number;
readonly renderWhitespace: 'none' | 'boundary' | 'all';
Expand Down

0 comments on commit 2032be3

Please sign in to comment.