mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Save editor cursor/scroll position when switching sql files (#1978)
* Save editor layouts when switching sql files * Move import * Restore the view state after laying out the editor
This commit is contained in:
committed by
Karl Burtram
parent
d20f24be18
commit
4bfa6b3a5d
@@ -10,7 +10,7 @@ import * as DOM from 'vs/base/browser/dom';
|
|||||||
|
|
||||||
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
|
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
|
||||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||||
import { IEditorControl, Position, IEditor } from 'vs/platform/editor/common/editor';
|
import { IEditorControl, Position, IEditor, IEditorInput } from 'vs/platform/editor/common/editor';
|
||||||
import { VerticalFlexibleSash, HorizontalFlexibleSash, IFlexibleSash } from 'sql/parts/query/views/flexibleSash';
|
import { VerticalFlexibleSash, HorizontalFlexibleSash, IFlexibleSash } from 'sql/parts/query/views/flexibleSash';
|
||||||
import { Orientation } from 'vs/base/browser/ui/sash/sash';
|
import { Orientation } from 'vs/base/browser/ui/sash/sash';
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ import { IEditorGroupService } from 'vs/workbench/services/group/common/groupSer
|
|||||||
import { CodeEditor } from 'vs/editor/browser/codeEditor';
|
import { CodeEditor } from 'vs/editor/browser/codeEditor';
|
||||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||||
import { IRange } from 'vs/editor/common/core/range';
|
import { IRange } from 'vs/editor/common/core/range';
|
||||||
|
import { IEditorViewState } from 'vs/editor/common/editorCommon';
|
||||||
|
|
||||||
import { QueryResultsInput } from 'sql/parts/query/common/queryResultsInput';
|
import { QueryResultsInput } from 'sql/parts/query/common/queryResultsInput';
|
||||||
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
||||||
@@ -87,6 +88,8 @@ export class QueryEditor extends BaseEditor {
|
|||||||
private _estimatedQueryPlanAction: EstimatedQueryPlanAction;
|
private _estimatedQueryPlanAction: EstimatedQueryPlanAction;
|
||||||
private _actualQueryPlanAction: ActualQueryPlanAction;
|
private _actualQueryPlanAction: ActualQueryPlanAction;
|
||||||
|
|
||||||
|
private _savedViewStates = new Map<IEditorInput, IEditorViewState>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ITelemetryService _telemetryService: ITelemetryService,
|
@ITelemetryService _telemetryService: ITelemetryService,
|
||||||
@IThemeService themeService: IThemeService,
|
@IThemeService themeService: IThemeService,
|
||||||
@@ -481,6 +484,8 @@ export class QueryEditor extends BaseEditor {
|
|||||||
private _updateInput(oldInput: QueryInput, newInput: QueryInput, options?: EditorOptions): TPromise<void> {
|
private _updateInput(oldInput: QueryInput, newInput: QueryInput, options?: EditorOptions): TPromise<void> {
|
||||||
|
|
||||||
if (this._sqlEditor) {
|
if (this._sqlEditor) {
|
||||||
|
let sqlEditorViewState = this._sqlEditor.getControl().saveViewState();
|
||||||
|
this._savedViewStates.set(this._sqlEditor.input, sqlEditorViewState);
|
||||||
this._sqlEditor.clearInput();
|
this._sqlEditor.clearInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,7 +562,12 @@ export class QueryEditor extends BaseEditor {
|
|||||||
// Run all three steps synchronously
|
// Run all three steps synchronously
|
||||||
return createEditors()
|
return createEditors()
|
||||||
.then(onEditorsCreated)
|
.then(onEditorsCreated)
|
||||||
.then(doLayout);
|
.then(doLayout)
|
||||||
|
.then(() => {
|
||||||
|
if (this._savedViewStates.has(newInput.sql)) {
|
||||||
|
this._sqlEditor.getControl().restoreViewState(this._savedViewStates.get(newInput.sql));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user