@@ -53,6 +53,14 @@ export class CodeplusInstance {
5353 }
5454 return "" ;
5555 }
56+ getRememberName ( ) {
57+ // Only want to remember the display name if there is one
58+ // so that `filename.js (GitHub)` syncs with `another.js (GitHub)`
59+ if ( this . displayName ) {
60+ return this . displayName ;
61+ }
62+ return this . filename ;
63+ }
5664 hasNav ( ) {
5765 return this . filename || this . displayName || this . groupName ;
5866 }
@@ -133,7 +141,7 @@ class CodeplusGroup {
133141 // this.onTabShown(this.tabs[index], this.instances[index]);
134142
135143 if ( remember && this . rememberTabSelections && this . tabs . length > 1 ) {
136- const name = this . instances [ index ] . getNavName ( ) ;
144+ const name = this . instances [ index ] . getRememberName ( ) ;
137145 setRememberedTab ( name ) ;
138146 this . onRememberTabSelection ( name ) ;
139147 }
@@ -206,7 +214,7 @@ class CodeplusGroup {
206214 var foundTab = false ;
207215 for ( const rememberedTab of rememberedTabs ) {
208216 for ( let i = 0 ; i < this . instances . length ; i ++ ) {
209- if ( this . instances [ i ] . getNavName ( ) === rememberedTab ) {
217+ if ( this . instances [ i ] . getRememberName ( ) === rememberedTab ) {
210218 this . showTab ( i ) ;
211219 foundTab = true ;
212220 }
@@ -332,7 +340,7 @@ class Codeplus {
332340 // Make all visible groups show the same tab if it exists
333341 this . groups . forEach ( ( group ) => {
334342 const index = group . instances . findIndex (
335- ( instance ) => instance . getNavName ( ) === name
343+ ( instance ) => instance . getRememberName ( ) === name
336344 ) ;
337345 if ( index !== - 1 ) {
338346 group . showTab ( index ) ;
0 commit comments