mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-22 08:09:42 +01:00
Default settings editor:
Fix layouting: Layout side by side editors before setting inputs Dispose: Do not dispose default settings model, this is messing up hidden areas
This commit is contained in:
@@ -125,7 +125,7 @@ export class SideBySideEditor extends BaseEditor {
|
||||
return TPromise.join([
|
||||
this._createEditor(<EditorInput>newInput.details, this.detailsEditorContainer),
|
||||
this._createEditor(<EditorInput>newInput.master, this.masterEditorContainer, options)
|
||||
]).then(result => this.onEditorsCreated(result[0], result[1]));
|
||||
]).then(result => this.onEditorsCreated(result[0], result[1], newInput.details, newInput.master));
|
||||
}
|
||||
|
||||
private _createEditor(editorInput: EditorInput, container: HTMLElement, options?: EditorOptions): TPromise<BaseEditor> {
|
||||
@@ -137,15 +137,15 @@ export class SideBySideEditor extends BaseEditor {
|
||||
.then((editor: BaseEditor) => {
|
||||
editor.create(new Builder(container));
|
||||
editor.setVisible(this.isVisible(), this.position);
|
||||
return editor.setInput(editorInput, options).then(() => editor);
|
||||
return editor;
|
||||
});
|
||||
}
|
||||
|
||||
private onEditorsCreated(details: BaseEditor, master: BaseEditor): void {
|
||||
private onEditorsCreated(details: BaseEditor, master: BaseEditor, detailsInput: EditorInput, masterInput: EditorInput): TPromise<void> {
|
||||
this.detailsEditor = details;
|
||||
this.masterEditor = master;
|
||||
this.dolayout(this.sash.getVerticalSashLeft());
|
||||
this.focus();
|
||||
return TPromise.join([this.detailsEditor.setInput(detailsInput), this.masterEditor.setInput(masterInput)]).then(() => this.focus());
|
||||
}
|
||||
|
||||
private createEditorContainers(): void {
|
||||
@@ -162,7 +162,7 @@ export class SideBySideEditor extends BaseEditor {
|
||||
}
|
||||
|
||||
private dolayout(splitPoint: number): void {
|
||||
if (!this.detailsEditor || !this.masterEditor) {
|
||||
if (!this.detailsEditor || !this.masterEditor || !this.dimension) {
|
||||
return;
|
||||
}
|
||||
const masterEditorWidth = this.dimension.width - splitPoint;
|
||||
|
||||
@@ -4,12 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
.settings-header-widget {
|
||||
display: none;
|
||||
border-bottom: 1px solid #efefef;
|
||||
}
|
||||
|
||||
.settings-header-widget.show {
|
||||
display: flex;
|
||||
border-bottom: 1px solid #efefef;
|
||||
}
|
||||
|
||||
.vs-dark .settings-header-widget {
|
||||
@@ -36,7 +32,6 @@
|
||||
}
|
||||
|
||||
.settings-header-widget > .settings-header-container > .settings-search-container > .settings-search-input {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,16 +175,12 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
|
||||
}
|
||||
|
||||
public layout(dimension: Dimension) {
|
||||
if (this.input && (<DefaultPreferencesEditorInput>this.input).isSettings) {
|
||||
const headerWidgetPosition = DOM.getDomNodePagePosition(this.defaultSettingHeaderWidget.domNode);
|
||||
this.defaultPreferencesEditor.layout({
|
||||
height: dimension.height - headerWidgetPosition.height,
|
||||
width: dimension.width
|
||||
});
|
||||
this.defaultSettingHeaderWidget.layout(this.defaultPreferencesEditor.getLayoutInfo());
|
||||
} else {
|
||||
this.defaultPreferencesEditor.layout(dimension);
|
||||
}
|
||||
this.defaultSettingHeaderWidget.layout(dimension);
|
||||
const headerWidgetPosition = DOM.getDomNodePagePosition(this.defaultSettingHeaderWidget.domNode);
|
||||
this.defaultPreferencesEditor.layout({
|
||||
height: dimension.height - headerWidgetPosition.height,
|
||||
width: dimension.width
|
||||
});
|
||||
}
|
||||
|
||||
public focus(): void {
|
||||
@@ -212,11 +208,9 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
|
||||
this.defaultPreferencesEditor.setModel(model);
|
||||
this.defaultPreferencesEditor.updateOptions(this.getCodeEditorOptions());
|
||||
if (input.isSettings) {
|
||||
this.defaultSettingHeaderWidget.show();
|
||||
this.defaultPreferencesEditor.onDidFocusEditorText(() => this.onEditorTextFocussed(), this.toDispose);
|
||||
} else {
|
||||
this.toDispose = dispose(this.toDispose);
|
||||
this.defaultSettingHeaderWidget.hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +224,6 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
|
||||
}
|
||||
|
||||
public clearInput(): void {
|
||||
this.disposeModel();
|
||||
this.saveState(<DefaultPreferencesEditorInput>this.input);
|
||||
if (this.inputDisposeListener) {
|
||||
this.inputDisposeListener.dispose();
|
||||
@@ -275,13 +268,6 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
|
||||
}
|
||||
}
|
||||
|
||||
private disposeModel() {
|
||||
const model = this.defaultPreferencesEditor.getModel();
|
||||
if (model) {
|
||||
model.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private reportFilteringUsed(filter: string): void {
|
||||
let data = {};
|
||||
data['filter'] = filter;
|
||||
@@ -583,6 +569,8 @@ export class SettingsGroupTitleRenderer extends Disposable implements HiddenArea
|
||||
|
||||
export class HiddenAreasRenderer extends Disposable {
|
||||
|
||||
private model: editorCommon.IModel;
|
||||
|
||||
constructor(private editor: ICodeEditor, private hiddenAreasProviders: HiddenAreasProvider[],
|
||||
@IInstantiationService private instantiationService: IInstantiationService
|
||||
) {
|
||||
@@ -593,12 +581,18 @@ export class HiddenAreasRenderer extends Disposable {
|
||||
}
|
||||
|
||||
public render() {
|
||||
this.model = this.editor.getModel();
|
||||
const ranges: editorCommon.IRange[] = [];
|
||||
for (const hiddenAreaProvider of this.hiddenAreasProviders) {
|
||||
ranges.push(...hiddenAreaProvider.hiddenAreas);
|
||||
}
|
||||
this.editor.setHiddenAreas(ranges);
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
this.editor.setHiddenAreas([]);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export class FilteredMatchesRenderer extends Disposable implements HiddenAreasProvider {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { Dimension } from 'vs/base/browser/builder';
|
||||
import { Widget } from 'vs/base/browser/ui/widget';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
@@ -188,6 +189,8 @@ export class DefaultSettingsHeaderWidget extends Widget {
|
||||
private create(parent: HTMLElement) {
|
||||
this.domNode = DOM.append(parent, DOM.$('div.settings-header-widget'));
|
||||
this.headerContainer = DOM.append(this.domNode, DOM.$('div.settings-header-container'));
|
||||
this.headerContainer.style.paddingLeft = '28px';
|
||||
this.headerContainer.style.paddingRight = '32px';
|
||||
const titleContainer = DOM.append(this.headerContainer, DOM.$('div.settings-title-container'));
|
||||
this.createInfoContainer(DOM.append(titleContainer, DOM.$('div.settings-info-container')));
|
||||
this.createSearchContainer(DOM.append(this.headerContainer, DOM.$('div.settings-search-container')));
|
||||
@@ -204,18 +207,8 @@ export class DefaultSettingsHeaderWidget extends Widget {
|
||||
ariaLabel: localize('SearchSettingsWidget.AriaLabel', "Search default settings"),
|
||||
placeholder: localize('SearchSettingsWidget.Placeholder', "Search Default Settings")
|
||||
}));
|
||||
this.inputBox.width = 280;
|
||||
this.inputBox.onDidChange(value => this._onDidChange.fire(value));
|
||||
this.onkeyup(this.inputBox.inputElement, (e) => this._onKeyUp(e));
|
||||
this.searchContainer.style.display = 'none';
|
||||
}
|
||||
|
||||
public show() {
|
||||
DOM.addClass(this.domNode, 'show');
|
||||
}
|
||||
|
||||
public hide() {
|
||||
DOM.removeClass(this.domNode, 'show');
|
||||
}
|
||||
|
||||
public focusTracker(): DOM.IFocusTracker {
|
||||
@@ -226,12 +219,8 @@ export class DefaultSettingsHeaderWidget extends Widget {
|
||||
this.inputBox.focus();
|
||||
}
|
||||
|
||||
public layout(editorLayoutInfo: editorCommon.EditorLayoutInfo): void {
|
||||
this.headerContainer.style.width = editorLayoutInfo.width - editorLayoutInfo.verticalScrollbarWidth + 'px';
|
||||
this.headerContainer.style.paddingLeft = editorLayoutInfo.contentLeft + 'px';
|
||||
this.searchContainer.style.width = editorLayoutInfo.contentWidth - editorLayoutInfo.glyphMarginWidth + 'px';
|
||||
this.inputBox.width = editorLayoutInfo.contentWidth - editorLayoutInfo.glyphMarginWidth;
|
||||
this.searchContainer.style.display = 'inherit';
|
||||
public layout(dimension: Dimension): void {
|
||||
this.inputBox.width = dimension.width - 65;
|
||||
}
|
||||
|
||||
private _onKeyUp(keyboardEvent: IKeyboardEvent): void {
|
||||
|
||||
Reference in New Issue
Block a user