@codingame/monaco-vscode-editor-service-override 2.2.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/tools/editor.js +31 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-editor-service-override",
3
- "version": "2.2.1",
3
+ "version": "3.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,7 +18,7 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@2.2.1",
21
+ "vscode": "npm:@codingame/monaco-vscode-api@3.0.0",
22
22
  "vscode-marked": "npm:marked@=3.0.2"
23
23
  }
24
24
  }
package/tools/editor.js CHANGED
@@ -192,8 +192,8 @@ let StandaloneEditorGroup = StandaloneEditorGroup_1 = class StandaloneEditorGrou
192
192
  this.onWillOpenEditor = this._onWillOpenEditor.event;
193
193
  this.id = --StandaloneEditorGroup_1.idCounter;
194
194
  this.index = -1;
195
- this.label = `standalone editor ${this.editor.getId()}`;
196
- this.ariaLabel = `standalone editor ${this.editor.getId()}`;
195
+ this.label = `standalone editor ${-this.id}`;
196
+ this.ariaLabel = `standalone editor ${-this.id}`;
197
197
  this.previewEditor = null;
198
198
  this.isLocked = true;
199
199
  this.stickyCount = 0;
@@ -201,8 +201,22 @@ let StandaloneEditorGroup = StandaloneEditorGroup_1 = class StandaloneEditorGrou
201
201
  this.findEditors = (resource) => this.pane != null && ( resource.toString()) === ( this.pane.input.resource.toString()) ? [this.pane.input] : [];
202
202
  this.getEditorByIndex = (index) => this.pane != null && index === 0 ? this.pane.input : undefined;
203
203
  this.getIndexOfEditor = (editorInput) => this.pane != null && this.pane.input === editorInput ? 0 : -1;
204
- this.openEditor = unsupported;
205
- this.openEditors = unsupported;
204
+ this.openEditor = async (editor) => {
205
+ if (editor.isDisposed()) {
206
+ return undefined;
207
+ }
208
+ if (editor instanceof TextResourceEditorInput && ( editor.resource.toString()) === this.pane?.input.resource.toString()) {
209
+ this.focus();
210
+ return this.pane;
211
+ }
212
+ return undefined;
213
+ };
214
+ this.openEditors = async (editors) => {
215
+ if (editors.length === 1) {
216
+ return this.openEditor(editors[0].editor);
217
+ }
218
+ return undefined;
219
+ };
206
220
  this.isPinned = () => false;
207
221
  this.isSticky = () => false;
208
222
  this.isActive = () => this.editor.hasWidgetFocus();
@@ -318,6 +332,7 @@ let StandaloneEditorGroup = StandaloneEditorGroup_1 = class StandaloneEditorGrou
318
332
  }
319
333
  focus() {
320
334
  this.editor.focus();
335
+ this.editor.getContainerDomNode().scrollIntoView();
321
336
  }
322
337
  };
323
338
  StandaloneEditorGroup.idCounter = 0;
@@ -397,15 +412,23 @@ let MonacoDelegateEditorGroupsService = class MonacoDelegateEditorGroupsService
397
412
  const codeEditorService = StandaloneServices.get(ICodeEditorService);
398
413
  const handleCodeEditor = (editor) => {
399
414
  if (editor instanceof StandaloneEditor) {
415
+ let timeout;
400
416
  const onEditorFocused = () => {
417
+ if (timeout != null)
418
+ window.clearTimeout(timeout);
401
419
  this.activeGroupOverride = this.additionalGroups.find(group => group.editor === editor);
402
420
  this._onDidChangeActiveGroup.fire(this.activeGroup);
403
421
  };
404
422
  const onEditorBlurred = () => {
405
- if (this.activeGroupOverride === this.additionalGroups.find(group => group.editor === editor)) {
406
- this.activeGroupOverride = undefined;
407
- this._onDidChangeActiveGroup.fire(this.activeGroup);
408
- }
423
+ if (timeout != null)
424
+ window.clearTimeout(timeout);
425
+ timeout = window.setTimeout(() => {
426
+ timeout = undefined;
427
+ if (this.activeGroupOverride === this.additionalGroups.find(group => group.editor === editor)) {
428
+ this.activeGroupOverride = undefined;
429
+ this._onDidChangeActiveGroup.fire(this.activeGroup);
430
+ }
431
+ }, 100);
409
432
  };
410
433
  editor.onDidFocusEditorText(onEditorFocused);
411
434
  editor.onDidFocusEditorWidget(onEditorFocused);