@@ -12,6 +12,22 @@ export class OpenSumiEditor extends OpenSumiView {
1212 } ) ;
1313 }
1414
15+ async getTab ( ) {
16+ const path = ( await this . filestatElement . getFsPath ( ) ) || '' ;
17+ const tabsItems = await ( await this . getTabElement ( ) ) ?. $$ ( "[class*='kt_editor_tab___']" ) ;
18+
19+ if ( ! tabsItems ) {
20+ return ;
21+ }
22+
23+ for ( const item of tabsItems ) {
24+ const uri = await item . getAttribute ( 'data-uri' ) ;
25+ if ( uri ?. includes ( path ) ) {
26+ return item ;
27+ }
28+ }
29+ }
30+
1531 async getCurrentTab ( ) {
1632 return await ( await this . getTabElement ( ) ) ?. waitForSelector ( "[class*='kt_editor_tab_current___']" ) ;
1733 }
@@ -24,13 +40,13 @@ export class OpenSumiEditor extends OpenSumiView {
2440 }
2541
2642 async isPreview ( ) {
27- const currentTab = await this . getCurrentTab ( ) ;
43+ const currentTab = await this . getTab ( ) ;
2844 const isPreview = ( await currentTab ?. getAttribute ( 'class' ) ) ?. includes ( 'kt_editor_tab_preview___' ) ;
2945 return ! ! isPreview ;
3046 }
3147
3248 async isDirty ( ) {
33- const dirtyIcon = await ( await this . getCurrentTab ( ) ) ?. $ ( "[class*='dirty___']" ) ;
49+ const dirtyIcon = await ( await this . getTab ( ) ) ?. $ ( "[class*='dirty___']" ) ;
3450 const className = await dirtyIcon ?. getAttribute ( 'class' ) ;
3551 const hidden = className ?. includes ( 'hidden__' ) ;
3652 return ! hidden ;
@@ -41,7 +57,7 @@ export class OpenSumiEditor extends OpenSumiView {
4157 if ( ! ( await this . isDirty ( ) ) ) {
4258 return ;
4359 }
44- const dirtyIcon = await ( await this . getCurrentTab ( ) ) ?. $ ( "[class*='dirty___']" ) ;
60+ const dirtyIcon = await ( await this . getTab ( ) ) ?. $ ( "[class*='dirty___']" ) ;
4561 await this . app . menubar . trigger ( 'File' , 'Save File' ) ;
4662 // waiting for saved
4763 await dirtyIcon ?. waitForElementState ( 'hidden' ) ;
0 commit comments