@@ -13,6 +13,7 @@ import { Action2, MenuId, MenuRegistry, registerAction2 } from 'vs/platform/acti
13
13
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService' ;
14
14
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
15
15
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
16
+ import { EditorResourceAccessor , SideBySideEditor } from 'vs/workbench/common/editor' ;
16
17
import { IDialogService } from 'vs/platform/dialogs/common/dialogs' ;
17
18
import { InstantiationType , registerSingleton } from 'vs/platform/instantiation/common/extensions' ;
18
19
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
@@ -26,6 +27,8 @@ import { Extensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common
26
27
import { ShareProviderCountContext , ShareService } from 'vs/workbench/contrib/share/browser/shareService' ;
27
28
import { IShareService } from 'vs/workbench/contrib/share/common/share' ;
28
29
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle' ;
30
+ import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
31
+ import { IProgressService , ProgressLocation } from 'vs/platform/progress/common/progress' ;
29
32
30
33
const targetMenus = [
31
34
MenuId . EditorContextShare ,
@@ -73,15 +76,23 @@ class ShareWorkbenchContribution {
73
76
74
77
override async run ( accessor : ServicesAccessor , ...args : any [ ] ) : Promise < void > {
75
78
const shareService = accessor . get ( IShareService ) ;
76
- const resourceUri = accessor . get ( IWorkspaceContextService ) . getWorkspace ( ) . folders [ 0 ] . uri ;
79
+ const activeEditor = accessor . get ( IEditorService ) ?. activeEditor ;
80
+ const resourceUri = ( activeEditor && EditorResourceAccessor . getOriginalUri ( activeEditor , { supportSideBySide : SideBySideEditor . PRIMARY } ) )
81
+ ?? accessor . get ( IWorkspaceContextService ) . getWorkspace ( ) . folders [ 0 ] . uri ;
77
82
const clipboardService = accessor . get ( IClipboardService ) ;
78
83
const dialogService = accessor . get ( IDialogService ) ;
79
84
const urlService = accessor . get ( IOpenerService ) ;
85
+ const progressService = accessor . get ( IProgressService ) ;
80
86
81
87
const uri = await shareService . provideShare ( { resourceUri } , new CancellationTokenSource ( ) . token ) ;
82
88
if ( uri ) {
83
89
const uriText = uri . toString ( ) ;
84
- await clipboardService . writeText ( uriText ) ;
90
+
91
+ await progressService . withProgress ( {
92
+ location : ProgressLocation . Window ,
93
+ detail : localize ( 'generating link' , 'Generating link...' )
94
+ } , ( ) => clipboardService . writeText ( uriText ) ) ;
95
+
85
96
dialogService . prompt (
86
97
{
87
98
type : Severity . Info ,
0 commit comments