mirror of https://github.com/coder/code-server.git
Add additional ide-api events
This commit is contained in:
parent
6c8e513e71
commit
7cc7aa51aa
|
@ -158,6 +158,19 @@ declare namespace ide {
|
|||
readonly notificationService: INotificationService;
|
||||
readonly menuRegistry: IMenuRegistry;
|
||||
readonly commandRegistry: ICommandRegistry;
|
||||
|
||||
onFileCreate(cb: (path: string) => void): void;
|
||||
onFileMove(cb: (path: string, target: string) => void): void;
|
||||
onFileDelete(cb: (path: string) => void): void;
|
||||
onFileSaved(cb: (path: string) => void): void;
|
||||
onFileCopy(cb: (path: string, target: string) => void): void;
|
||||
|
||||
onModelAdded(cb: (path: string, languageId: string) => void): void;
|
||||
onModelRemoved(cb: (path: string, languageId: string) => void): void;
|
||||
onModelLanguageChange(cb: (path: string, languageId: string, oldLanguageId: string) => void): void;
|
||||
|
||||
onTerminalAdded(cb: () => void): void;
|
||||
onTerminalRemoved(cb: () => void): void;
|
||||
};
|
||||
|
||||
export enum Severity {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@coder/ide-api",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"typings": "api.d.ts",
|
||||
"author": "Coder",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -8,6 +8,10 @@ import product from "./fill/product";
|
|||
import "./vscode.scss";
|
||||
import { MenuId, MenuRegistry } from "vs/platform/actions/common/actions";
|
||||
import { CommandsRegistry } from "vs/platform/commands/common/commands";
|
||||
import { IFileService, FileOperation } from "vs/platform/files/common/files";
|
||||
import { ITextFileService } from "vs/workbench/services/textfile/common/textfiles";
|
||||
import { IModelService } from "vs/editor/common/services/modelService";
|
||||
import { ITerminalService } from "vs/workbench/contrib/terminal/common/terminal";
|
||||
// NOTE: shouldn't import anything from VS Code here or anything that will
|
||||
// depend on a synchronous fill like `os`.
|
||||
|
||||
|
@ -34,6 +38,63 @@ class VSClient extends IdeClient {
|
|||
// tslint:disable-next-line:no-any
|
||||
statusbarService: getService<IStatusbarService>(IStatusbarService) as any,
|
||||
notificationService: getService<INotificationService>(INotificationService),
|
||||
|
||||
onFileCreate: (cb): void => {
|
||||
getService<IFileService>(IFileService).onAfterOperation((e) => {
|
||||
if (e.operation === FileOperation.CREATE) {
|
||||
cb(e.resource.path);
|
||||
}
|
||||
});
|
||||
},
|
||||
onFileMove: (cb): void => {
|
||||
getService<IFileService>(IFileService).onAfterOperation((e) => {
|
||||
if (e.operation === FileOperation.MOVE) {
|
||||
cb(e.resource.path, e.target ? e.target.resource.path : undefined!);
|
||||
}
|
||||
});
|
||||
},
|
||||
onFileDelete: (cb): void => {
|
||||
getService<IFileService>(IFileService).onAfterOperation((e) => {
|
||||
if (e.operation === FileOperation.DELETE) {
|
||||
cb(e.resource.path);
|
||||
}
|
||||
});
|
||||
},
|
||||
onFileSaved: (cb): void => {
|
||||
getService<ITextFileService>(ITextFileService).models.onModelSaved((e) => {
|
||||
cb(e.resource.path);
|
||||
});
|
||||
},
|
||||
onFileCopy: (cb): void => {
|
||||
getService<IFileService>(IFileService).onAfterOperation((e) => {
|
||||
if (e.operation === FileOperation.COPY) {
|
||||
cb(e.resource.path, e.target ? e.target.resource.path : undefined!);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onModelAdded: (cb): void => {
|
||||
getService<IModelService>(IModelService).onModelAdded((e) => {
|
||||
cb(e.uri.path, e.getLanguageIdentifier().language);
|
||||
});
|
||||
},
|
||||
onModelRemoved: (cb): void => {
|
||||
getService<IModelService>(IModelService).onModelRemoved((e) => {
|
||||
cb(e.uri.path, e.getLanguageIdentifier().language);
|
||||
});
|
||||
},
|
||||
onModelLanguageChange: (cb): void => {
|
||||
getService<IModelService>(IModelService).onModelModeChanged((e) => {
|
||||
cb(e.model.uri.path, e.model.getLanguageIdentifier().language, e.oldModeId);
|
||||
});
|
||||
},
|
||||
|
||||
onTerminalAdded: (cb): void => {
|
||||
getService<ITerminalService>(ITerminalService).onInstanceCreated(() => cb());
|
||||
},
|
||||
onTerminalRemoved: (cb): void => {
|
||||
getService<ITerminalService>(ITerminalService).onInstanceDisposed(() => cb());
|
||||
},
|
||||
},
|
||||
|
||||
// @ts-ignore
|
||||
|
|
Loading…
Reference in New Issue