File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,15 @@ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
22import {
33 driveFileBrowser ,
44 openDriveDialogPlugin ,
5- launcherPlugin
5+ launcherPlugin ,
6+ sessionContextPatch
67} from './plugins' ;
78
89const plugins : JupyterFrontEndPlugin < any > [ ] = [
910 driveFileBrowser ,
1011 openDriveDialogPlugin ,
11- launcherPlugin
12+ launcherPlugin ,
13+ sessionContextPatch
1214] ;
1315
1416export default plugins ;
Original file line number Diff line number Diff line change 11export * from './driveBrowserPlugin' ;
22export * from './launcherPlugin' ;
33export * from './driveDialogPlugin' ;
4+ export * from './sessionContextPatch' ;
Original file line number Diff line number Diff line change 1+ import {
2+ JupyterFrontEndPlugin ,
3+ JupyterFrontEnd
4+ } from '@jupyterlab/application' ;
5+ import { SessionContext } from '@jupyterlab/apputils' ;
6+ import {
7+ IDocumentManager ,
8+ IDocumentWidgetOpener
9+ } from '@jupyterlab/docmanager' ;
10+
11+ /**
12+ * A plugin to patch the session context path so it includes the drive name.
13+ * associated with.
14+ */
15+ export const sessionContextPatch : JupyterFrontEndPlugin < void > = {
16+ id : '@jupyterlite/application-extension:session-context-patch' ,
17+ autoStart : true ,
18+ requires : [ IDocumentManager , IDocumentWidgetOpener ] ,
19+ activate : (
20+ app : JupyterFrontEnd ,
21+ docManager : IDocumentManager ,
22+ widgetOpener : IDocumentWidgetOpener
23+ ) => {
24+ const contents = app . serviceManager . contents ;
25+
26+ widgetOpener . opened . connect ( ( _ , widget ) => {
27+ const context = docManager . contextForWidget ( widget ) ;
28+ const driveName = contents . driveName ( context ?. path ?? '' ) ;
29+ if ( driveName === '' ) {
30+ // do nothing if this is the default drive
31+ return ;
32+ }
33+ const sessionContext = widget . context . sessionContext as SessionContext ;
34+
35+ // Path the session context to include the drive name
36+ sessionContext [ '_path' ] = context ?. path ;
37+ } ) ;
38+ }
39+ } ;
You can’t perform that action at this time.
0 commit comments