@@ -26,9 +26,9 @@ import { Git, IGitExtension } from './tokens';
26
26
import { addCloneButton } from './widgets/gitClone' ;
27
27
import { GitWidget } from './widgets/GitWidget' ;
28
28
29
+ export { DiffModel } from './components/diff/model' ;
29
30
export { NotebookDiff } from './components/diff/NotebookDiff' ;
30
31
export { PlainTextDiff } from './components/diff/PlainTextDiff' ;
31
- export { DiffModel } from './components/diff/model' ;
32
32
export { Git , IGitExtension } from './tokens' ;
33
33
34
34
/**
@@ -74,7 +74,11 @@ async function activate(
74
74
let settings : ISettingRegistry . ISettings ;
75
75
let serverSettings : Git . IServerSettings ;
76
76
// Get a reference to the default file browser extension
77
- let filebrowser = factory . tracker . currentWidget ;
77
+ // We don't use the current tracked browser because extension like jupyterlab-github
78
+ // or jupyterlab-gitlab are defining new filebrowsers that we don't support.
79
+ // And it is unlikely that another browser than the default will be used.
80
+ // Ref: https://github.com/jupyterlab/jupyterlab-git/issues/1014
81
+ const fileBrowser = factory . defaultBrowser ;
78
82
translator = translator || nullTranslator ;
79
83
const trans = translator . load ( 'jupyterlab_git' ) ;
80
84
@@ -133,8 +137,8 @@ async function activate(
133
137
gitExtension = new GitExtension ( docmanager , app . docRegistry , settings ) ;
134
138
135
139
// Whenever we restore the application, sync the Git extension path
136
- Promise . all ( [ app . restored , filebrowser . model . restored ] ) . then ( ( ) => {
137
- gitExtension . pathRepository = filebrowser . model . path ;
140
+ Promise . all ( [ app . restored , fileBrowser . model . restored ] ) . then ( ( ) => {
141
+ gitExtension . pathRepository = fileBrowser . model . path ;
138
142
} ) ;
139
143
140
144
const onPathChanged = (
@@ -145,28 +149,15 @@ async function activate(
145
149
} ;
146
150
147
151
// Whenever the file browser path changes, sync the Git extension path
148
- filebrowser . model . pathChanged . connect ( onPathChanged ) ;
152
+ fileBrowser . model . pathChanged . connect ( onPathChanged ) ;
149
153
150
154
const refreshBrowser = ( ) => {
151
- filebrowser . model . refresh ( ) ;
155
+ fileBrowser . model . refresh ( ) ;
152
156
} ;
153
157
154
158
// Whenever the `HEAD` of the Git repository changes, refresh the file browser
155
159
gitExtension . headChanged . connect ( refreshBrowser ) ;
156
160
157
- // Handle file browser changes
158
- factory . tracker . currentChanged . connect ( ( _ , browser ) => {
159
- filebrowser . model . pathChanged . disconnect ( onPathChanged ) ;
160
-
161
- filebrowser = browser ;
162
- gitExtension . pathRepository = filebrowser . model . path ;
163
- filebrowser . model . pathChanged . connect ( onPathChanged ) ;
164
-
165
- if ( settings ) {
166
- addCloneButton ( gitExtension , filebrowser , app . commands ) ;
167
- }
168
- } ) ;
169
-
170
161
// Whenever a user adds/renames/saves/deletes/modifies a file within the lab environment, refresh the Git status
171
162
app . serviceManager . contents . fileChanged . connect ( ( ) =>
172
163
gitExtension . refreshStatus ( )
@@ -175,14 +166,14 @@ async function activate(
175
166
// Provided we were able to load application settings, create the extension widgets
176
167
if ( settings ) {
177
168
// Add JupyterLab commands
178
- addCommands ( app , gitExtension , factory . tracker , settings , trans ) ;
169
+ addCommands ( app , gitExtension , fileBrowser . model , settings , trans ) ;
179
170
180
171
// Create the Git widget sidebar
181
172
const gitPlugin = new GitWidget (
182
173
gitExtension ,
183
174
settings ,
184
175
app . commands ,
185
- factory . tracker ,
176
+ fileBrowser . model ,
186
177
trans
187
178
) ;
188
179
gitPlugin . id = 'jp-git-sessions' ;
@@ -205,13 +196,13 @@ async function activate(
205
196
}
206
197
207
198
// Add a clone button to the file browser extension toolbar
208
- addCloneButton ( gitExtension , filebrowser , app . commands ) ;
199
+ addCloneButton ( gitExtension , fileBrowser , app . commands ) ;
209
200
210
201
// Add the status bar widget
211
202
addStatusBarWidget ( statusBar , gitExtension , settings , trans ) ;
212
203
213
204
// Add the context menu items for the default file browser
214
- addFileBrowserContextMenu ( gitExtension , factory . tracker , app . contextMenu ) ;
205
+ addFileBrowserContextMenu ( gitExtension , fileBrowser , app . contextMenu ) ;
215
206
}
216
207
217
208
// Register diff providers
0 commit comments