@@ -19,7 +19,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
19
19
import { editorBackground , editorForeground , resolveColorValue } from 'vs/platform/theme/common/colorRegistry' ;
20
20
import { IThemeService , registerThemingParticipant } from 'vs/platform/theme/common/themeService' ;
21
21
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane' ;
22
- import { IEditorMemento , IEditorOpenContext } from 'vs/workbench/common/editor' ;
22
+ import { EditorPaneSelectionChangeReason , IEditorMemento , IEditorOpenContext , IEditorPaneSelectionChangeEvent } from 'vs/workbench/common/editor' ;
23
23
import { getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions' ;
24
24
import { InteractiveEditorInput } from 'vs/workbench/contrib/interactive/browser/interactiveEditorInput' ;
25
25
import { CodeCellLayoutChangeEvent , IActiveNotebookEditorDelegate , ICellViewModel , INotebookEditorViewState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
@@ -54,9 +54,10 @@ import { ModesHoverController } from 'vs/editor/contrib/hover/browser/hover';
54
54
import { MarkerController } from 'vs/editor/contrib/gotoError/browser/gotoError' ;
55
55
import { EditorInput } from 'vs/workbench/common/editor/editorInput' ;
56
56
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfiguration' ;
57
- import { ITextEditorOptions } from 'vs/platform/editor/common/editor' ;
57
+ import { ITextEditorOptions , TextEditorSelectionSource } from 'vs/platform/editor/common/editor' ;
58
58
import { INotebookExecutionStateService } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService' ;
59
59
import { NOTEBOOK_KERNEL } from 'vs/workbench/contrib/notebook/common/notebookContextKeys' ;
60
+ import { ICursorPositionChangedEvent } from 'vs/editor/common/cursorEvents' ;
60
61
61
62
const DECORATION_KEY = 'interactiveInputDecoration' ;
62
63
const INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'InteractiveEditorViewState' ;
@@ -110,6 +111,8 @@ export class InteractiveEditor extends EditorPane {
110
111
111
112
#onDidFocusWidget = this . _register ( new Emitter < void > ( ) ) ;
112
113
override get onDidFocus ( ) : Event < void > { return this . #onDidFocusWidget. event ; }
114
+ #onDidChangeSelection = this . _register ( new Emitter < IEditorPaneSelectionChangeEvent > ( ) ) ;
115
+ readonly onDidChangeSelection = this . #onDidChangeSelection. event ;
113
116
114
117
constructor (
115
118
@ITelemetryService telemetryService : ITelemetryService ,
@@ -436,6 +439,10 @@ export class InteractiveEditor extends EditorPane {
436
439
}
437
440
} ) ) ;
438
441
442
+ this . #widgetDisposableStore. add ( this . #codeEditorWidget. onDidChangeCursorPosition ( e => this . #onDidChangeSelection. fire ( { reason : this . #toEditorPaneSelectionChangeReason( e ) } ) ) ) ;
443
+ this . #widgetDisposableStore. add ( this . #codeEditorWidget. onDidChangeModelContent ( ( ) => this . #onDidChangeSelection. fire ( { reason : EditorPaneSelectionChangeReason . EDIT } ) ) ) ;
444
+
445
+
439
446
this . #widgetDisposableStore. add ( this . #notebookKernelService. onDidChangeNotebookAffinity ( this . #syncWithKernel, this ) ) ;
440
447
this . #widgetDisposableStore. add ( this . #notebookKernelService. onDidChangeSelectedNotebooks ( this . #syncWithKernel, this ) ) ;
441
448
@@ -495,6 +502,15 @@ export class InteractiveEditor extends EditorPane {
495
502
this . #syncWithKernel( ) ;
496
503
}
497
504
505
+ #toEditorPaneSelectionChangeReason( e : ICursorPositionChangedEvent ) : EditorPaneSelectionChangeReason {
506
+ switch ( e . source ) {
507
+ case TextEditorSelectionSource . PROGRAMMATIC : return EditorPaneSelectionChangeReason . PROGRAMMATIC ;
508
+ case TextEditorSelectionSource . NAVIGATION : return EditorPaneSelectionChangeReason . NAVIGATION ;
509
+ case TextEditorSelectionSource . JUMP : return EditorPaneSelectionChangeReason . JUMP ;
510
+ default : return EditorPaneSelectionChangeReason . USER ;
511
+ }
512
+ }
513
+
498
514
#lastCell: ICellViewModel | undefined = undefined ;
499
515
#lastCellDisposable = new DisposableStore ( ) ;
500
516
#state: ScrollingState = ScrollingState . Initial ;
0 commit comments