Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Dima <alexdima@microsoft.com>2022-05-10 17:24:45 +0300
committerGitHub <noreply@github.com>2022-05-10 17:24:45 +0300
commite5b5dc2417e3ead7416f4b6ea341da90b7a4742a (patch)
tree1aeab2b9f16fba6f805af04c200bf01e08186feb
parent9a1e8d12fb12c8c5b659fb65292675d165bfa1f3 (diff)
parentf26cc2c1a66b2f3b43c30901e0cf8e8479b88059 (diff)
Merge pull request #148777 from CodinGame/add-get-editors-api
Add editor monitoring methods in monaco api
-rw-r--r--src/vs/editor/standalone/browser/standaloneEditor.ts32
-rw-r--r--src/vs/monaco.d.ts16
2 files changed, 47 insertions, 1 deletions
diff --git a/src/vs/editor/standalone/browser/standaloneEditor.ts b/src/vs/editor/standalone/browser/standaloneEditor.ts
index 04e0f6fd2ca..0cad477dd6e 100644
--- a/src/vs/editor/standalone/browser/standaloneEditor.ts
+++ b/src/vs/editor/standalone/browser/standaloneEditor.ts
@@ -13,7 +13,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
import { DiffNavigator, IDiffNavigator } from 'vs/editor/browser/widget/diffNavigator';
import { ApplyUpdateResult, ConfigurationChangedEvent, EditorOptions } from 'vs/editor/common/config/editorOptions';
import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo';
-import { EditorType } from 'vs/editor/common/editorCommon';
+import { EditorType, IDiffEditor } from 'vs/editor/common/editorCommon';
import { FindMatch, ITextModel, TextModelResolvedOptions } from 'vs/editor/common/model';
import * as languages from 'vs/editor/common/languages';
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
@@ -53,6 +53,33 @@ export function onDidCreateEditor(listener: (codeEditor: ICodeEditor) => void):
}
/**
+ * Emitted when an diff editor is created.
+ * @event
+ */
+export function onDidCreateDiffEditor(listener: (diffEditor: IDiffEditor) => void): IDisposable {
+ const codeEditorService = StandaloneServices.get(ICodeEditorService);
+ return codeEditorService.onDiffEditorAdd((editor) => {
+ listener(<IDiffEditor>editor);
+ });
+}
+
+/**
+ * Get all the created editors.
+ */
+export function getEditors(): readonly ICodeEditor[] {
+ const codeEditorService = StandaloneServices.get(ICodeEditorService);
+ return codeEditorService.listCodeEditors();
+}
+
+/**
+ * Get all the created diff editors.
+ */
+export function getDiffEditors(): readonly IDiffEditor[] {
+ const codeEditorService = StandaloneServices.get(ICodeEditorService);
+ return codeEditorService.listDiffEditors();
+}
+
+/**
* Create a new diff editor under `domElement`.
* `domElement` should be empty (not contain other dom nodes).
* The editor will read the size of `domElement`.
@@ -283,7 +310,10 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
return {
// methods
create: <any>create,
+ getEditors: <any>getEditors,
+ getDiffEditors: <any>getDiffEditors,
onDidCreateEditor: <any>onDidCreateEditor,
+ onDidCreateDiffEditor: <any>onDidCreateDiffEditor,
createDiffEditor: <any>createDiffEditor,
createDiffNavigator: <any>createDiffNavigator,
diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts
index 86ea824eef8..83086200c6f 100644
--- a/src/vs/monaco.d.ts
+++ b/src/vs/monaco.d.ts
@@ -891,6 +891,22 @@ declare namespace monaco.editor {
export function onDidCreateEditor(listener: (codeEditor: ICodeEditor) => void): IDisposable;
/**
+ * Emitted when an diff editor is created.
+ * @event
+ */
+ export function onDidCreateDiffEditor(listener: (diffEditor: IDiffEditor) => void): IDisposable;
+
+ /**
+ * Get all the created editors.
+ */
+ export function getEditors(): readonly ICodeEditor[];
+
+ /**
+ * Get all the created diff editors.
+ */
+ export function getDiffEditors(): readonly IDiffEditor[];
+
+ /**
* Create a new diff editor under `domElement`.
* `domElement` should be empty (not contain other dom nodes).
* The editor will read the size of `domElement`.