mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 17:23:40 -05:00
Merge from vscode e558dc6ea73a75bd69d7a0b485f0e7e4194c66bf (#6864)
This commit is contained in:
@@ -32,6 +32,7 @@ export interface IInputOptions extends IInputBoxStyles {
|
||||
readonly type?: string;
|
||||
readonly validationOptions?: IInputValidationOptions;
|
||||
readonly flexibleHeight?: boolean;
|
||||
readonly flexibleWidth?: boolean;
|
||||
readonly flexibleMaxHeight?: number;
|
||||
readonly actions?: ReadonlyArray<IAction>;
|
||||
|
||||
@@ -185,6 +186,13 @@ export class InputBox extends Widget {
|
||||
this.mirror.innerHTML = ' ';
|
||||
|
||||
this.scrollableElement = new ScrollableElement(this.element, { vertical: ScrollbarVisibility.Auto });
|
||||
|
||||
if (this.options.flexibleWidth) {
|
||||
this.input.setAttribute('wrap', 'off');
|
||||
this.mirror.style.whiteSpace = 'pre';
|
||||
this.mirror.style.wordWrap = 'initial';
|
||||
}
|
||||
|
||||
dom.append(container, this.scrollableElement.getDomNode());
|
||||
this._register(this.scrollableElement);
|
||||
|
||||
@@ -345,12 +353,36 @@ export class InputBox extends Widget {
|
||||
}
|
||||
|
||||
public set width(width: number) {
|
||||
this.input.style.width = width + 'px';
|
||||
if (this.options.flexibleHeight && this.options.flexibleWidth) {
|
||||
// textarea with horizontal scrolling
|
||||
let horizontalPadding = 0;
|
||||
if (this.mirror) {
|
||||
const paddingLeft = parseFloat(this.mirror.style.paddingLeft || '') || 0;
|
||||
const paddingRight = parseFloat(this.mirror.style.paddingRight || '') || 0;
|
||||
horizontalPadding = paddingLeft + paddingRight;
|
||||
}
|
||||
this.input.style.width = (width - horizontalPadding) + 'px';
|
||||
} else {
|
||||
this.input.style.width = width + 'px';
|
||||
}
|
||||
|
||||
if (this.mirror) {
|
||||
this.mirror.style.width = width + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
public set paddingRight(paddingRight: number) {
|
||||
if (this.options.flexibleHeight && this.options.flexibleWidth) {
|
||||
this.input.style.width = `calc(100% - ${paddingRight}px)`;
|
||||
} else {
|
||||
this.input.style.paddingRight = paddingRight + 'px';
|
||||
}
|
||||
|
||||
if (this.mirror) {
|
||||
this.mirror.style.paddingRight = paddingRight + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
private updateScrollDimensions(): void {
|
||||
if (typeof this.cachedContentHeight !== 'number' || typeof this.cachedHeight !== 'number') {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user