Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger CHANGE_CELL_LANGUAGE on "Select language" in the empty notebook cell hint. #242835

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class EmptyTextEditorHintContribution implements IEditorContribution {
protected toDispose: IDisposable[];
private textHintContentWidget: EmptyTextEditorHintContentWidget | undefined;

protected readonly changeLanguageCommandId: string = ChangeLanguageAction.ID;

constructor(
protected readonly editor: ICodeEditor,
@IEditorGroupsService private readonly editorGroupsService: IEditorGroupsService,
Expand Down Expand Up @@ -149,7 +151,8 @@ export class EmptyTextEditorHintContribution implements IEditorContribution {
this.chatAgentService,
this.telemetryService,
this.productService,
this.contextMenuService
this.contextMenuService,
this.changeLanguageCommandId
);
} else if (!shouldRenderHint && this.textHintContentWidget) {
this.textHintContentWidget.dispose();
Expand Down Expand Up @@ -184,6 +187,7 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {
private readonly telemetryService: ITelemetryService,
private readonly productService: IProductService,
private readonly contextMenuService: IContextMenuService,
private readonly changeLanguageCommandId: string,
) {
this.toDispose = new DisposableStore();
this.toDispose.add(this.editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => {
Expand Down Expand Up @@ -345,10 +349,10 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {
// Need to focus editor before so current editor becomes active and the command is properly executed
this.editor.focus();
this.telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', {
id: ChangeLanguageAction.ID,
id: this.changeLanguageCommandId,
from: 'hint'
});
await this.commandService.executeCommand(ChangeLanguageAction.ID);
await this.commandService.executeCommand(this.changeLanguageCommandId);
this.editor.focus();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ITelemetryService } from '../../../../../../platform/telemetry/common/t
import { IChatAgentService } from '../../../../chat/common/chatAgents.js';
import { EmptyTextEditorHintContribution, IEmptyTextEditorHintOptions } from '../../../../codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js';
import { IInlineChatSessionService } from '../../../../inlineChat/browser/inlineChatSessionService.js';
import { getNotebookEditorFromEditorPane } from '../../notebookBrowser.js';
import { getNotebookEditorFromEditorPane, CHANGE_CELL_LANGUAGE } from '../../notebookBrowser.js';
import { IEditorGroupsService } from '../../../../../services/editor/common/editorGroupsService.js';
import { IEditorService } from '../../../../../services/editor/common/editorService.js';

Expand Down Expand Up @@ -59,6 +59,8 @@ export class EmptyCellEditorHintContribution extends EmptyTextEditorHintContribu
this.toDispose.push(activeEditor.onDidChangeActiveCell(() => this.update()));
}

protected override readonly changeLanguageCommandId: string = CHANGE_CELL_LANGUAGE;

protected override _getOptions(): IEmptyTextEditorHintOptions {
return { clickable: false };
}
Expand Down