@codingame/monaco-vscode-interactive-service-override 6.0.2 → 7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-interactive-service-override",
3
- "version": "6.0.2",
3
+ "version": "7.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -26,6 +26,6 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "vscode": "npm:@codingame/monaco-vscode-api@6.0.2"
29
+ "vscode": "npm:@codingame/monaco-vscode-api@7.0.0"
30
30
  }
31
31
  }
@@ -16,6 +16,7 @@ import { peekViewBorder } from 'vscode/vscode/vs/editor/contrib/peekView/browser
16
16
  import { Context } from 'vscode/vscode/vs/editor/contrib/suggest/browser/suggest';
17
17
  import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
18
18
  import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
19
+ import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
19
20
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
20
21
  import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
21
22
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
@@ -46,15 +47,19 @@ import { INTERACTIVE_INPUT_CURSOR_BOUNDARY, InteractiveWindowSetting } from './i
46
47
  import 'vscode/vscode/vs/base/common/event';
47
48
  import { InteractiveEditor } from './interactiveEditor.js';
48
49
  import { InteractiveEditorInput } from 'vscode/vscode/vs/workbench/contrib/interactive/browser/interactiveEditorInput';
50
+ import 'vscode/vscode/vs/base/common/collections';
49
51
  import 'vscode/vscode/vs/base/common/map';
50
52
  import { IInteractiveHistoryService } from 'vscode/vscode/vs/workbench/contrib/interactive/browser/interactiveHistoryService.service';
51
53
  import { NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
52
- import { executeIcon } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
54
+ import { configIcon, executeIcon } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
53
55
  import { INotebookEditorService } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service';
54
56
  import { INTERACTIVE_WINDOW_EDITOR_ID, CellUri, NotebookWorkingCopyTypeIdentifier, CellEditType, CellKind, NotebookSetting } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
55
57
  import { InteractiveWindowOpen } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
56
58
  import { INotebookKernelService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookKernelService.service';
57
59
  import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
60
+ import { executeReplInput } from '../../replNotebook/browser/repl.contribution.js';
61
+ import { ReplEditor } from '../../replNotebook/browser/replEditor.js';
62
+ import { ReplEditorInput } from '../../replNotebook/browser/replEditorInput.js';
58
63
  import { columnToEditorGroup } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupColumn';
59
64
  import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
60
65
  import { RegisteredEditorPriority } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
@@ -79,7 +84,7 @@ let InteractiveDocumentContribution = class InteractiveDocumentContribution exte
79
84
  providerDisplayName: 'Interactive Notebook',
80
85
  displayName: 'Interactive',
81
86
  filenamePattern: ['*.interactive'],
82
- exclusive: true
87
+ priority: RegisteredEditorPriority.exclusive
83
88
  }));
84
89
  }
85
90
  editorResolverService.registerEditor(`${Schemas.vscodeInteractiveInput}:/**`, {
@@ -343,10 +348,10 @@ registerAction2(class extends Action2 {
343
348
  InteractiveEditorInput.setName(notebookUri, title);
344
349
  logService.debug('Open new interactive window:', ( (notebookUri.toString())), ( (inputUri.toString())));
345
350
  if (id) {
346
- const allKernels = kernelService.getMatchingKernel({ uri: notebookUri, viewType: 'interactive' }).all;
351
+ const allKernels = kernelService.getMatchingKernel({ uri: notebookUri, notebookType: 'interactive' }).all;
347
352
  const preferredKernel = allKernels.find(kernel => kernel.id === id);
348
353
  if (preferredKernel) {
349
- kernelService.preselectKernelForNotebook(preferredKernel, { uri: notebookUri, viewType: 'interactive' });
354
+ kernelService.preselectKernelForNotebook(preferredKernel, { uri: notebookUri, notebookType: 'interactive' });
350
355
  }
351
356
  }
352
357
  historyService.clearHistory(notebookUri);
@@ -357,13 +362,34 @@ registerAction2(class extends Action2 {
357
362
  return { notebookUri, inputUri, notebookEditorId: editorControl?.notebookEditor?.getId() };
358
363
  }
359
364
  });
365
+ registerAction2(class extends Action2 {
366
+ constructor() {
367
+ super({
368
+ id: 'interactive.configure',
369
+ title: ( localize2WithPath(_moduleId, 2, 'Configure input box behavior')),
370
+ category: interactiveWindowCategory,
371
+ f1: false,
372
+ icon: configIcon,
373
+ menu: {
374
+ id: MenuId.InteractiveInputConfig
375
+ }
376
+ });
377
+ }
378
+ run(accessor, ...args) {
379
+ accessor.get(ICommandService).executeCommand('workbench.action.openSettings', '@tag:replExecute');
380
+ }
381
+ });
360
382
  registerAction2(class extends Action2 {
361
383
  constructor() {
362
384
  super({
363
385
  id: 'interactive.execute',
364
- title: ( localize2WithPath(_moduleId, 2, 'Execute Code')),
386
+ title: ( localize2WithPath(_moduleId, 3, 'Execute Code')),
365
387
  category: interactiveWindowCategory,
366
388
  keybinding: [{
389
+ when: ( (ContextKeyExpr.equals('activeEditor', 'workbench.editor.interactive'))),
390
+ primary: KeyMod.CtrlCmd | KeyCode.Enter,
391
+ weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
392
+ }, {
367
393
  when: ( (ContextKeyExpr.and(
368
394
  (ContextKeyExpr.equals('activeEditor', 'workbench.editor.interactive')),
369
395
  (ContextKeyExpr.equals('config.interactiveWindow.executeWithShiftEnter', true))
@@ -377,17 +403,13 @@ registerAction2(class extends Action2 {
377
403
  ))),
378
404
  primary: KeyCode.Enter,
379
405
  weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
380
- }, {
381
- when: ( (ContextKeyExpr.equals('activeEditor', 'workbench.editor.interactive'))),
382
- primary: KeyMod.WinCtrl | KeyCode.Enter,
383
- win: {
384
- primary: KeyMod.CtrlCmd | KeyCode.Enter
385
- },
386
- weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
387
406
  }],
388
407
  menu: [
389
408
  {
390
409
  id: MenuId.InteractiveInputExecute
410
+ },
411
+ {
412
+ id: MenuId.ReplInputExecute
391
413
  }
392
414
  ],
393
415
  icon: executeIcon,
@@ -410,20 +432,27 @@ registerAction2(class extends Action2 {
410
432
  const historyService = accessor.get(IInteractiveHistoryService);
411
433
  const notebookEditorService = accessor.get(INotebookEditorService);
412
434
  let editorControl;
435
+ let isReplEditor = false;
413
436
  if (context) {
414
437
  const resourceUri = URI.revive(context);
415
- const editors = editorService.findEditors(resourceUri)
416
- .filter(id => id.editor instanceof InteractiveEditorInput && id.editor.resource?.toString() === ( (resourceUri.toString())));
417
- if (editors.length) {
418
- const editorInput = editors[0].editor;
419
- const currentGroup = editors[0].groupId;
420
- const editor = await editorService.openEditor(editorInput, currentGroup);
421
- editorControl = editor?.getControl();
438
+ const editors = editorService.findEditors(resourceUri);
439
+ for (const found of editors) {
440
+ if (found.editor.typeId === ReplEditorInput.ID || found.editor.typeId === InteractiveEditorInput.ID) {
441
+ const editor = await editorService.openEditor(found.editor, found.groupId);
442
+ editorControl = editor?.getControl();
443
+ isReplEditor = found.editor.typeId === ReplEditorInput.ID;
444
+ break;
445
+ }
422
446
  }
423
447
  }
424
448
  else {
449
+ const editor = editorService.activeEditorPane;
450
+ isReplEditor = editor instanceof ReplEditor;
425
451
  editorControl = editorService.activeEditorPane?.getControl();
426
452
  }
453
+ if (editorControl && isReplEditor) {
454
+ executeReplInput(accessor, editorControl);
455
+ }
427
456
  if (editorControl && editorControl.notebookEditor && editorControl.codeEditor) {
428
457
  const notebookDocument = editorControl.notebookEditor.textModel;
429
458
  const textModel = editorControl.codeEditor.getModel();
@@ -475,7 +504,7 @@ registerAction2(class extends Action2 {
475
504
  constructor() {
476
505
  super({
477
506
  id: 'interactive.input.clear',
478
- title: ( localize2WithPath(_moduleId, 3, 'Clear the interactive window input editor contents')),
507
+ title: ( localize2WithPath(_moduleId, 4, 'Clear the interactive window input editor contents')),
479
508
  category: interactiveWindowCategory,
480
509
  f1: false
481
510
  });
@@ -497,19 +526,28 @@ registerAction2(class extends Action2 {
497
526
  constructor() {
498
527
  super({
499
528
  id: 'interactive.history.previous',
500
- title: ( localize2WithPath(_moduleId, 4, 'Previous value in history')),
529
+ title: ( localize2WithPath(_moduleId, 5, 'Previous value in history')),
501
530
  category: interactiveWindowCategory,
502
531
  f1: false,
503
- keybinding: {
504
- when: ( (ContextKeyExpr.and(
505
- (ContextKeyExpr.equals('activeEditor', 'workbench.editor.interactive')),
506
- (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('bottom')),
507
- (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('none')),
508
- (Context.Visible.toNegated())
509
- ))),
510
- primary: KeyCode.UpArrow,
511
- weight: KeybindingWeight.WorkbenchContrib
512
- },
532
+ keybinding: [{
533
+ when: ( (ContextKeyExpr.and(
534
+ (ContextKeyExpr.equals('activeEditor', 'workbench.editor.interactive')),
535
+ (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('bottom')),
536
+ (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('none')),
537
+ (Context.Visible.toNegated())
538
+ ))),
539
+ primary: KeyCode.UpArrow,
540
+ weight: KeybindingWeight.WorkbenchContrib
541
+ }, {
542
+ when: ( (ContextKeyExpr.and(
543
+ (ContextKeyExpr.equals('activeEditor', 'workbench.editor.repl')),
544
+ (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('bottom')),
545
+ (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('none')),
546
+ (Context.Visible.toNegated())
547
+ ))),
548
+ primary: KeyCode.UpArrow,
549
+ weight: KeybindingWeight.WorkbenchContrib
550
+ }]
513
551
  });
514
552
  }
515
553
  async run(accessor) {
@@ -532,19 +570,28 @@ registerAction2(class extends Action2 {
532
570
  constructor() {
533
571
  super({
534
572
  id: 'interactive.history.next',
535
- title: ( localize2WithPath(_moduleId, 5, 'Next value in history')),
573
+ title: ( localize2WithPath(_moduleId, 6, 'Next value in history')),
536
574
  category: interactiveWindowCategory,
537
575
  f1: false,
538
- keybinding: {
539
- when: ( (ContextKeyExpr.and(
540
- (ContextKeyExpr.equals('activeEditor', 'workbench.editor.interactive')),
541
- (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('top')),
542
- (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('none')),
543
- (Context.Visible.toNegated())
544
- ))),
545
- primary: KeyCode.DownArrow,
546
- weight: KeybindingWeight.WorkbenchContrib
547
- },
576
+ keybinding: [{
577
+ when: ( (ContextKeyExpr.and(
578
+ (ContextKeyExpr.equals('activeEditor', 'workbench.editor.interactive')),
579
+ (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('top')),
580
+ (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('none')),
581
+ (Context.Visible.toNegated())
582
+ ))),
583
+ primary: KeyCode.DownArrow,
584
+ weight: KeybindingWeight.WorkbenchContrib
585
+ }, {
586
+ when: ( (ContextKeyExpr.and(
587
+ (ContextKeyExpr.equals('activeEditor', 'workbench.editor.repl')),
588
+ (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('top')),
589
+ (INTERACTIVE_INPUT_CURSOR_BOUNDARY.notEqualsTo('none')),
590
+ (Context.Visible.toNegated())
591
+ ))),
592
+ primary: KeyCode.DownArrow,
593
+ weight: KeybindingWeight.WorkbenchContrib
594
+ }],
548
595
  });
549
596
  }
550
597
  async run(accessor) {
@@ -567,7 +614,7 @@ registerAction2(class extends Action2 {
567
614
  constructor() {
568
615
  super({
569
616
  id: 'interactive.scrollToTop',
570
- title: ( localizeWithPath(_moduleId, 6, 'Scroll to Top')),
617
+ title: ( localizeWithPath(_moduleId, 7, 'Scroll to Top')),
571
618
  keybinding: {
572
619
  when: ( (ContextKeyExpr.equals('activeEditor', 'workbench.editor.interactive'))),
573
620
  primary: KeyMod.CtrlCmd | KeyCode.Home,
@@ -592,7 +639,7 @@ registerAction2(class extends Action2 {
592
639
  constructor() {
593
640
  super({
594
641
  id: 'interactive.scrollToBottom',
595
- title: ( localizeWithPath(_moduleId, 7, 'Scroll to Bottom')),
642
+ title: ( localizeWithPath(_moduleId, 8, 'Scroll to Bottom')),
596
643
  keybinding: {
597
644
  when: ( (ContextKeyExpr.equals('activeEditor', 'workbench.editor.interactive'))),
598
645
  primary: KeyMod.CtrlCmd | KeyCode.End,
@@ -618,7 +665,7 @@ registerAction2(class extends Action2 {
618
665
  constructor() {
619
666
  super({
620
667
  id: 'interactive.input.focus',
621
- title: ( localize2WithPath(_moduleId, 8, 'Focus Input Editor')),
668
+ title: ( localize2WithPath(_moduleId, 9, 'Focus Input Editor')),
622
669
  category: interactiveWindowCategory,
623
670
  menu: {
624
671
  id: MenuId.CommandPalette,
@@ -652,7 +699,7 @@ registerAction2(class extends Action2 {
652
699
  constructor() {
653
700
  super({
654
701
  id: 'interactive.history.focus',
655
- title: ( localize2WithPath(_moduleId, 9, 'Focus History')),
702
+ title: ( localize2WithPath(_moduleId, 10, 'Focus History')),
656
703
  category: interactiveWindowCategory,
657
704
  menu: {
658
705
  id: MenuId.CommandPalette,
@@ -676,7 +723,7 @@ registerColor('interactive.activeCodeBorder', {
676
723
  hcLight: contrastBorder
677
724
  }, ( localizeWithPath(
678
725
  _moduleId,
679
- 10,
726
+ 11,
680
727
  'The border color for the current interactive code cell when the editor has focus.'
681
728
  )));
682
729
  registerColor('interactive.inactiveCodeBorder', {
@@ -686,7 +733,7 @@ registerColor('interactive.inactiveCodeBorder', {
686
733
  hcLight: PANEL_BORDER
687
734
  }, ( localizeWithPath(
688
735
  _moduleId,
689
- 11,
736
+ 12,
690
737
  'The border color for the current interactive code cell when the editor does not have focus.'
691
738
  )));
692
739
  ( (Registry.as(Extensions.Configuration))).registerConfiguration({
@@ -699,7 +746,7 @@ registerColor('interactive.inactiveCodeBorder', {
699
746
  default: true,
700
747
  markdownDescription: ( localizeWithPath(
701
748
  _moduleId,
702
- 12,
749
+ 13,
703
750
  "Automatically scroll the interactive window to show the output of the last statement executed. If this value is false, the window will only scroll if the last cell was already the one scrolled to."
704
751
  ))
705
752
  },
@@ -708,18 +755,29 @@ registerColor('interactive.inactiveCodeBorder', {
708
755
  default: false,
709
756
  markdownDescription: ( localizeWithPath(
710
757
  _moduleId,
711
- 13,
758
+ 14,
712
759
  "Prompt to save the interactive window when it is closed. Only new interactive windows will be affected by this setting change."
713
760
  ))
714
761
  },
715
- ['interactiveWindow.executeWithShiftEnter']: {
762
+ [InteractiveWindowSetting.executeWithShiftEnter]: {
763
+ type: 'boolean',
764
+ default: false,
765
+ markdownDescription: ( localizeWithPath(
766
+ _moduleId,
767
+ 15,
768
+ "Execute the Interactive Window (REPL) input box with shift+enter, so that enter can be used to create a newline."
769
+ )),
770
+ tags: ['replExecute']
771
+ },
772
+ [InteractiveWindowSetting.showExecutionHint]: {
716
773
  type: 'boolean',
717
774
  default: true,
718
775
  markdownDescription: ( localizeWithPath(
719
776
  _moduleId,
720
- 14,
721
- "Execute the interactive window (REPL) input box with shift+enter, so that enter can be used to create a newline."
722
- ))
777
+ 16,
778
+ "Display a hint in the Interactive Window (REPL) input box to indicate how to execute code."
779
+ )),
780
+ tags: ['replExecute']
723
781
  }
724
782
  }
725
783
  });
@@ -2,7 +2,9 @@ import { RawContextKey } from 'vscode/vscode/vs/platform/contextkey/common/conte
2
2
 
3
3
  const INTERACTIVE_INPUT_CURSOR_BOUNDARY = ( new RawContextKey('interactiveInputCursorAtBoundary', 'none'));
4
4
  const InteractiveWindowSetting = {
5
- interactiveWindowAlwaysScrollOnNewCell: 'interactiveWindow.alwaysScrollOnNewCell'
5
+ interactiveWindowAlwaysScrollOnNewCell: 'interactiveWindow.alwaysScrollOnNewCell',
6
+ executeWithShiftEnter: 'interactiveWindow.executeWithShiftEnter',
7
+ showExecutionHint: 'interactiveWindow.showExecutionHint'
6
8
  };
7
9
 
8
10
  export { INTERACTIVE_INPUT_CURSOR_BOUNDARY, InteractiveWindowSetting };