File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
extensions/ql-vscode/src/model-editor Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,15 @@ export class ModelEditorModule extends DisposableObject {
128128 return ;
129129 }
130130
131+ const existingViews = this . editorViewTracker . getViews (
132+ db . databaseUri . toString ( ) ,
133+ ) ;
134+ if ( existingViews . length > 0 ) {
135+ await Promise . all ( existingViews . map ( ( view ) => view . focusView ( ) ) ) ;
136+
137+ return ;
138+ }
139+
131140 return withProgress (
132141 async ( progress ) => {
133142 const maxStep = 4 ;
@@ -192,6 +201,17 @@ export class ModelEditorModule extends DisposableObject {
192201 maxStep,
193202 } ) ;
194203
204+ // Check again just before opening the editor to ensure no model editor has been opened between
205+ // our first check and now.
206+ const existingViews = this . editorViewTracker . getViews (
207+ db . databaseUri . toString ( ) ,
208+ ) ;
209+ if ( existingViews . length > 0 ) {
210+ await Promise . all ( existingViews . map ( ( view ) => view . focusView ( ) ) ) ;
211+
212+ return ;
213+ }
214+
195215 const view = new ModelEditorView (
196216 this . app ,
197217 this . modelingStore ,
Original file line number Diff line number Diff line change @@ -352,6 +352,10 @@ export class ModelEditorView extends AbstractWebview<
352352 return this . databaseItem . databaseUri . toString ( ) ;
353353 }
354354
355+ public async focusView ( ) : Promise < void > {
356+ this . panel ?. reveal ( ) ;
357+ }
358+
355359 public async revealMethod ( method : Method ) : Promise < void > {
356360 this . panel ?. reveal ( ) ;
357361
@@ -520,6 +524,15 @@ export class ModelEditorView extends AbstractWebview<
520524 return ;
521525 }
522526
527+ let existingViews = this . viewTracker . getViews (
528+ addedDatabase . databaseUri . toString ( ) ,
529+ ) ;
530+ if ( existingViews . length > 0 ) {
531+ await Promise . all ( existingViews . map ( ( view ) => view . focusView ( ) ) ) ;
532+
533+ return ;
534+ }
535+
523536 const modelFile = await pickExtensionPack (
524537 this . cliServer ,
525538 addedDatabase ,
@@ -532,6 +545,17 @@ export class ModelEditorView extends AbstractWebview<
532545 return ;
533546 }
534547
548+ // Check again just before opening the editor to ensure no model editor has been opened between
549+ // our first check and now.
550+ existingViews = this . viewTracker . getViews (
551+ addedDatabase . databaseUri . toString ( ) ,
552+ ) ;
553+ if ( existingViews . length > 0 ) {
554+ await Promise . all ( existingViews . map ( ( view ) => view . focusView ( ) ) ) ;
555+
556+ return ;
557+ }
558+
535559 const view = new ModelEditorView (
536560 this . app ,
537561 this . modelingStore ,
You can’t perform that action at this time.
0 commit comments