Skip to content

Commit

Permalink
provides onDidSaveTextDocument
Browse files Browse the repository at this point in the history
Change-Id: I14378927257c0f93a48731d00ba6c906380cc45f
Signed-off-by: Florent BENOIT <fbenoit@redhat.com>
  • Loading branch information
benoitf committed Oct 4, 2018
1 parent dfb3f4c commit a94cec0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/plugin-ext/src/plugin/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export class DocumentsExtImpl implements DocumentsExt {
private _onDidAddDocument = new Emitter<theia.TextDocument>();
private _onDidRemoveDocument = new Emitter<theia.TextDocument>();
private _onDidChangeDocument = new Emitter<theia.TextDocumentChangeEvent>();
private _onDidSaveDocument = new Emitter<theia.TextDocument>();
private _onDidSaveTextDocument = new Emitter<theia.TextDocument>();

readonly onDidAddDocument: Event<theia.TextDocument> = this._onDidAddDocument.event;
readonly onDidRemoveDocument: Event<theia.TextDocument> = this._onDidRemoveDocument.event;
readonly onDidChangeDocument: Event<theia.TextDocumentChangeEvent> = this._onDidChangeDocument.event;
readonly onDidSaveDocument: Event<theia.TextDocument> = this._onDidSaveDocument.event;
readonly onDidSaveTextDocument: Event<theia.TextDocument> = this._onDidSaveTextDocument.event;

private proxy: DocumentsMain;
private documentLoader = new Map<string, Promise<DocumentDataExt | undefined>>();
Expand Down Expand Up @@ -74,7 +74,7 @@ export class DocumentsExtImpl implements DocumentsExt {
const data = this.editorsAndDocuments.getDocument(uriString);
this.$acceptDirtyStateChanged(strUrl, false);
if (data) {
this._onDidSaveDocument.fire(data.document);
this._onDidSaveTextDocument.fire(data.document);
}
}
$acceptDirtyStateChanged(strUrl: UriComponents, isDirty: boolean): void {
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ export function createAPIFactory(rpc: RPCProtocol, pluginManager: PluginManager)
onDidOpenTextDocument(listener, thisArg?, disposables?) {
return documents.onDidAddDocument(listener, thisArg, disposables);
},

onDidSaveTextDocument(listener, thisArg?, disposables?) {
return documents.onDidSaveTextDocument(listener, thisArg, disposables);
},

getConfiguration(section?, resource?): theia.WorkspaceConfiguration {
return preferenceRegistryExt.getConfiguration(section, resource);
},
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2663,6 +2663,11 @@ declare module '@theia/plugin' {
*/
export const onDidChangeTextDocument: Event<TextDocumentChangeEvent>;

/**
* An event that is emitted when a [text document](#TextDocument) is saved to disk.
*/
export const onDidSaveTextDocument: Event<TextDocument>;

/**
* Opens a document. Will return early if this document is already open. Otherwise
* the document is loaded and the [didOpen](#workspace.onDidOpenTextDocument)-event fires.
Expand Down

0 comments on commit a94cec0

Please sign in to comment.