@@ -35,7 +35,7 @@ import { EditorDropTarget } from 'vs/workbench/browser/parts/editor/editorDropTa
3535import { localize } from 'vs/nls' ;
3636import { Color } from 'vs/base/common/color' ;
3737import { CenteredViewLayout } from 'vs/base/browser/ui/centered/centeredViewLayout' ;
38- import { IView } from 'vs/base/browser/ui/grid/gridview' ;
38+ import { IView , orthogonal } from 'vs/base/browser/ui/grid/gridview' ;
3939
4040interface IEditorPartUIState {
4141 serializedGrid : ISerializedGrid ;
@@ -414,7 +414,9 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
414414 const gridDescriptor = createSerializedGrid ( {
415415 orientation : this . toGridViewOrientation (
416416 layout . orientation ,
417- ( this . gridWidget . orientation === Orientation . VERTICAL ) ? Orientation . HORIZONTAL : Orientation . VERTICAL // fix https://github.com/Microsoft/vscode/issues/52975
417+ this . isTwoDimensionalGrid ( ) ?
418+ this . gridWidget . orientation : // preserve original orientation for 2-dimensional grids
419+ orthogonal ( this . gridWidget . orientation ) // otherwise flip (fix https://github.com/Microsoft/vscode/issues/52975)
418420 ) ,
419421 groups : layout . groups
420422 } ) ;
@@ -444,6 +446,17 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
444446 }
445447 }
446448
449+ private isTwoDimensionalGrid ( ) : boolean {
450+ const views = this . gridWidget . getViews ( ) ;
451+ if ( isGridBranchNode ( views ) ) {
452+ // the grid is 2-dimensional if any children
453+ // of the grid is a branch node
454+ return views . children . some ( child => isGridBranchNode ( child ) ) ;
455+ }
456+
457+ return false ;
458+ }
459+
447460 addGroup ( location : IEditorGroupView | GroupIdentifier , direction : GroupDirection , options ?: IAddGroupOptions ) : IEditorGroupView {
448461 const locationView = this . assertGroupView ( location ) ;
449462
0 commit comments