@@ -8,6 +8,10 @@ import product from "./fill/product";
88import "./vscode.scss" ;
99import { MenuId , MenuRegistry } from "vs/platform/actions/common/actions" ;
1010import { CommandsRegistry } from "vs/platform/commands/common/commands" ;
11+ import { IFileService , FileOperation } from "vs/platform/files/common/files" ;
12+ import { ITextFileService } from "vs/workbench/services/textfile/common/textfiles" ;
13+ import { IModelService } from "vs/editor/common/services/modelService" ;
14+ import { ITerminalService } from "vs/workbench/contrib/terminal/common/terminal" ;
1115// NOTE: shouldn't import anything from VS Code here or anything that will
1216// depend on a synchronous fill like `os`.
1317
@@ -34,6 +38,63 @@ class VSClient extends IdeClient {
3438 // tslint:disable-next-line:no-any
3539 statusbarService : getService < IStatusbarService > ( IStatusbarService ) as any ,
3640 notificationService : getService < INotificationService > ( INotificationService ) ,
41+
42+ onFileCreate : ( cb ) : void => {
43+ getService < IFileService > ( IFileService ) . onAfterOperation ( ( e ) => {
44+ if ( e . operation === FileOperation . CREATE ) {
45+ cb ( e . resource . path ) ;
46+ }
47+ } ) ;
48+ } ,
49+ onFileMove : ( cb ) : void => {
50+ getService < IFileService > ( IFileService ) . onAfterOperation ( ( e ) => {
51+ if ( e . operation === FileOperation . MOVE ) {
52+ cb ( e . resource . path , e . target ? e . target . resource . path : undefined ! ) ;
53+ }
54+ } ) ;
55+ } ,
56+ onFileDelete : ( cb ) : void => {
57+ getService < IFileService > ( IFileService ) . onAfterOperation ( ( e ) => {
58+ if ( e . operation === FileOperation . DELETE ) {
59+ cb ( e . resource . path ) ;
60+ }
61+ } ) ;
62+ } ,
63+ onFileSaved : ( cb ) : void => {
64+ getService < ITextFileService > ( ITextFileService ) . models . onModelSaved ( ( e ) => {
65+ cb ( e . resource . path ) ;
66+ } ) ;
67+ } ,
68+ onFileCopy : ( cb ) : void => {
69+ getService < IFileService > ( IFileService ) . onAfterOperation ( ( e ) => {
70+ if ( e . operation === FileOperation . COPY ) {
71+ cb ( e . resource . path , e . target ? e . target . resource . path : undefined ! ) ;
72+ }
73+ } ) ;
74+ } ,
75+
76+ onModelAdded : ( cb ) : void => {
77+ getService < IModelService > ( IModelService ) . onModelAdded ( ( e ) => {
78+ cb ( e . uri . path , e . getLanguageIdentifier ( ) . language ) ;
79+ } ) ;
80+ } ,
81+ onModelRemoved : ( cb ) : void => {
82+ getService < IModelService > ( IModelService ) . onModelRemoved ( ( e ) => {
83+ cb ( e . uri . path , e . getLanguageIdentifier ( ) . language ) ;
84+ } ) ;
85+ } ,
86+ onModelLanguageChange : ( cb ) : void => {
87+ getService < IModelService > ( IModelService ) . onModelModeChanged ( ( e ) => {
88+ cb ( e . model . uri . path , e . model . getLanguageIdentifier ( ) . language , e . oldModeId ) ;
89+ } ) ;
90+ } ,
91+
92+ onTerminalAdded : ( cb ) : void => {
93+ getService < ITerminalService > ( ITerminalService ) . onInstanceCreated ( ( ) => cb ( ) ) ;
94+ } ,
95+ onTerminalRemoved : ( cb ) : void => {
96+ getService < ITerminalService > ( ITerminalService ) . onInstanceDisposed ( ( ) => cb ( ) ) ;
97+ } ,
3798 } ,
3899
39100 // @ts -ignore
0 commit comments