File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/vs/workbench/contrib/notebook/browser/controller/chat Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -784,6 +784,27 @@ export class NotebookChatController extends Disposable implements INotebookEdito
784784
785785
786786 dismiss ( ) {
787+ // move focus back to the cell above
788+ if ( this . _widget ) {
789+ const widgetIndex = this . _widget . afterModelPosition ;
790+ const currentFocus = this . _notebookEditor . getFocus ( ) ;
791+
792+ if ( currentFocus . start === widgetIndex && currentFocus . end === widgetIndex ) {
793+ // focus is on the widget
794+ if ( widgetIndex === 0 ) {
795+ // on top of all cells
796+ if ( this . _notebookEditor . getLength ( ) > 0 ) {
797+ this . _notebookEditor . focusNotebookCell ( this . _notebookEditor . cellAt ( 0 ) ! , 'container' ) ;
798+ }
799+ } else {
800+ const cell = this . _notebookEditor . cellAt ( widgetIndex - 1 ) ;
801+ if ( cell ) {
802+ this . _notebookEditor . focusNotebookCell ( cell , 'container' ) ;
803+ }
804+ }
805+ }
806+ }
807+
787808 this . _ctxCellWidgetFocused . set ( false ) ;
788809 this . _ctxUserDidEdit . set ( false ) ;
789810 this . _sessionCtor ?. cancel ( ) ;
You can’t perform that action at this time.
0 commit comments