Skip to content

Commit

Permalink
Dragging a diff view to another editor group loses scroll position (fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Aug 13, 2020
1 parent ece8141 commit fca5c66
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/vs/editor/browser/editorBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1055,3 +1055,14 @@ export function getCodeEditor(thing: any): ICodeEditor | null {

return null;
}

/**
*@internal
*/
export function getIEditor(thing: any): editorCommon.IEditor | null {
if (isCodeEditor(thing) || isDiffEditor(thing)) {
return thing;
}

return null;
}
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Event } from 'vs/base/common/event';
import { IConfigurationChangeEvent, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ISerializableView } from 'vs/base/browser/ui/grid/grid';
import { getCodeEditor } from 'vs/editor/browser/editorBrowser';
import { getIEditor } from 'vs/editor/browser/editorBrowser';
import { IEditorOptions } from 'vs/platform/editor/common/editor';
import { IEditorService, IResourceEditorInputType } from 'vs/workbench/services/editor/common/editorService';

Expand Down Expand Up @@ -132,7 +132,7 @@ export interface IEditorGroupView extends IDisposable, ISerializableView, IEdito
}

export function getActiveTextEditorOptions(group: IEditorGroup, expectedActiveEditor?: IEditorInput, presetOptions?: EditorOptions): EditorOptions {
const activeGroupCodeEditor = group.activeEditorPane ? getCodeEditor(group.activeEditorPane.getControl()) : undefined;
const activeGroupCodeEditor = group.activeEditorPane ? getIEditor(group.activeEditorPane.getControl()) : undefined;
if (activeGroupCodeEditor) {
if (!expectedActiveEditor || expectedActiveEditor.matches(group.activeEditor)) {
return TextEditorOptions.fromEditor(activeGroupCodeEditor, presetOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ScrollType, IEditor, ICodeEditorViewState, IDiffEditorViewState } from 'vs/editor/common/editorCommon';
import { once } from 'vs/base/common/functional';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { getCodeEditor } from 'vs/editor/browser/editorBrowser';
import { getIEditor } from 'vs/editor/browser/editorBrowser';
import { withNullAsUndefined } from 'vs/base/common/types';
import { Codicon, stripCodicons } from 'vs/base/common/codicons';

Expand Down Expand Up @@ -134,7 +134,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
this.editorViewState = {
group: activeEditorPane.group,
editor: activeEditorPane.input,
state: withNullAsUndefined(getCodeEditor(activeEditorPane.getControl())?.saveViewState())
state: withNullAsUndefined(getIEditor(activeEditorPane.getControl())?.saveViewState())
};
}
}
Expand Down

0 comments on commit fca5c66

Please sign in to comment.