Merge branch 'master' into feature/nativeNotebook

This commit is contained in:
AbbiePetcht
2018-10-17 10:58:49 -07:00
12 changed files with 69 additions and 21 deletions

View File

@@ -39,6 +39,7 @@ export default class EditorComponent extends ComponentBase implements IComponent
private _languageMode: string;
private _uri: string;
private _isAutoResizable: boolean;
private _minimumHeight: number;
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@@ -79,6 +80,9 @@ export default class EditorComponent extends ComponentBase implements IComponent
this._register(this._editorModel.onDidChangeContent(e => {
this.content = this._editorModel.getValue();
if (this._isAutoResizable) {
if (this._minimumHeight) {
this._editor.setMinimumHeight(this._minimumHeight);
}
this._editor.setHeightToScrollHeight();
}
@@ -109,7 +113,8 @@ export default class EditorComponent extends ComponentBase implements IComponent
let height: number = this.convertSizeToNumber(this.height);
if (this._isAutoResizable) {
height = this._editor.scrollHeight;
this._editor.setHeightToScrollHeight();
height = Math.max(this._editor.scrollHeight, this._minimumHeight ? this._minimumHeight : 0);
}
this._editor.layout(new DOM.Dimension(
width && width > 0 ? width : DOM.getContentWidth(this._el.nativeElement),
@@ -152,6 +157,7 @@ export default class EditorComponent extends ComponentBase implements IComponent
// Intentionally always updating editorUri as it's wiped out by parent setProperties call.
this.editorUri = this._uri;
this._isAutoResizable = this.isAutoResizable;
this._minimumHeight = this.minimumHeight;
}
// CSS-bound properties
@@ -179,6 +185,14 @@ export default class EditorComponent extends ComponentBase implements IComponent
this.setPropertyFromUI<sqlops.EditorProperties, boolean>((properties, isAutoResizable) => { properties.isAutoResizable = isAutoResizable; }, newValue);
}
public get minimumHeight(): number {
return this.getPropertyOrDefault<sqlops.EditorProperties, number>((props) => props.minimumHeight, this._editor.minimumHeight);
}
public set minimumHeight(newValue: number) {
this.setPropertyFromUI<sqlops.EditorProperties, number>((properties, minimumHeight) => { properties.minimumHeight = minimumHeight; }, newValue);
}
public get editorUri(): string {
return this.getPropertyOrDefault<sqlops.EditorProperties, string>((props) => props.editorUri, '');
}

View File

@@ -34,6 +34,7 @@ export class QueryTextEditor extends BaseTextEditor {
public static ID = 'modelview.editors.textEditor';
private _dimension: DOM.Dimension;
private _config: editorCommon.IConfiguration;
private _minHeight: number;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IInstantiationService instantiationService: IInstantiationService,
@@ -116,6 +117,11 @@ export class QueryTextEditor extends BaseTextEditor {
this._config = new Configuration(undefined, editorWidget.getDomNode());
}
let editorHeightUsingLines = this._config.editor.lineHeight * editorWidget.getModel().getLineCount();
this.setHeight(editorHeightUsingLines);
let editorHeightUsingMinHeight = Math.max(editorHeightUsingLines, this._minHeight);
this.setHeight(editorHeightUsingMinHeight);
}
public setMinimumHeight(height: number) : void {
this._minHeight = height;
}
}

View File

@@ -184,6 +184,7 @@ export default class QueryRunner {
this._echoedResultSet.clear();
this._debouncedMessage.clear();
this._debouncedResultSet.clear();
this._planXml = new Deferred<string>();
let ownerUri = this.uri;
this._batchSets = [];
this._hasCompleted = false;
@@ -343,7 +344,11 @@ export default class QueryRunner {
}
// handle getting queryPlanxml if we need too
if (this.isQueryPlan) {
this.getQueryRows(0, 1, 0, 0).then(e => this._planXml.resolve(e.resultSubset.rows[0][0].displayValue));
// check if this result has show plan, this needs work, it won't work for any other provider
let hasShowPlan = !!result.resultSetSummary.columnInfo.find(e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan');
if (hasShowPlan) {
this.getQueryRows(0, 1, result.resultSetSummary.batchId, result.resultSetSummary.id).then(e => this._planXml.resolve(e.resultSubset.rows[0][0].displayValue));
}
}
if (batchSet) {
// Store the result set in the batch and emit that a result set has completed

View File

@@ -41,7 +41,7 @@ export class QueryPlanView implements IPanelView {
}
}
container.appendChild(this.container);
container.style.overflow = 'scroll';
this.container.style.overflow = 'scroll';
}
public layout(dimension: Dimension): void {

View File

@@ -595,6 +595,10 @@ declare module 'sqlops' {
* The languge mode for this text editor. The language mode is SQL by default.
*/
languageMode?: string;
/**
* Minimum height for editor component
*/
minimumHeight?: number;
}
export interface ButtonProperties extends ComponentProperties, ComponentWithIcon {
@@ -722,6 +726,11 @@ declare module 'sqlops' {
*/
isAutoResizable: boolean;
/**
* Minimum height for editor component
*/
minimumHeight: number;
}
export interface ButtonComponent extends Component, ButtonProperties {

View File

@@ -913,6 +913,14 @@ class EditorWrapper extends ComponentWrapper implements sqlops.EditorComponent {
this.setProperty('isAutoResizable', v);
}
public get minimumHeight(): number {
return this.properties['minimumHeight'];
}
public set minimumHeight(v: number) {
this.setProperty('minimumHeight', v);
}
public get onContentChanged(): vscode.Event<any> {
let emitter = this._emitterMap.get(ComponentEventType.onDidChange);
return emitter && emitter.event;