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

disable editor hint mouse click in empty cell editor. #194743

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Registry.as<IConfigurationMigrationRegistry>(Extensions.ConfigurationMigration)
])
}]);

export interface IEmptyTextEditorHintOptions {
readonly clickable?: boolean;
}

export const emptyTextEditorHintSetting = 'workbench.editor.empty.hint';
export class EmptyTextEditorHintContribution implements IEditorContribution {

Expand Down Expand Up @@ -92,6 +96,10 @@ export class EmptyTextEditorHintContribution implements IEditorContribution {
}));
}

protected _getOptions(): IEmptyTextEditorHintOptions {
return { clickable: true };
}

protected _shouldRenderHint() {
const configValue = this.configurationService.getValue(emptyTextEditorHintSetting);
if (configValue === 'hidden') {
Expand Down Expand Up @@ -123,6 +131,7 @@ export class EmptyTextEditorHintContribution implements IEditorContribution {
if (this._shouldRenderHint()) {
this.textHintContentWidget = new EmptyTextEditorHintContentWidget(
this.editor,
this._getOptions(),
this.editorGroupsService,
this.commandService,
this.configurationService,
Expand Down Expand Up @@ -151,6 +160,7 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {

constructor(
private readonly editor: ICodeEditor,
private readonly options: IEmptyTextEditorHintOptions,
private readonly editorGroupsService: IEditorGroupsService,
private readonly commandService: ICommandService,
private readonly configurationService: IConfigurationService,
Expand Down Expand Up @@ -236,11 +246,17 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {
const actionPart = localize('emptyHintText', 'Press {0} to ask {1} to do something. ', keybindingHintLabel, providerName);

const [before, after] = actionPart.split(keybindingHintLabel).map((fragment) => {
const hintPart = $('a', undefined, fragment);
hintPart.style.fontStyle = 'italic';
hintPart.style.cursor = 'pointer';
hintPart.onclick = handleClick;
return hintPart;
if (this.options.clickable) {
const hintPart = $('a', undefined, fragment);
hintPart.style.fontStyle = 'italic';
hintPart.style.cursor = 'pointer';
hintPart.onclick = handleClick;
return hintPart;
} else {
const hintPart = $('span', undefined, fragment);
hintPart.style.fontStyle = 'italic';
return hintPart;
}
});

hintElement.appendChild(before);
Expand All @@ -249,8 +265,11 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {
label.set(keybindingHint);
label.element.style.width = 'min-content';
label.element.style.display = 'inline';
label.element.style.cursor = 'pointer';
label.element.onclick = handleClick;

if (this.options.clickable) {
label.element.style.cursor = 'pointer';
label.element.onclick = handleClick;
}

hintElement.appendChild(after);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IProductService } from 'vs/platform/product/common/productService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { EmptyTextEditorHintContribution } from 'vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint';
import { EmptyTextEditorHintContribution, IEmptyTextEditorHintOptions } from 'vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint';
import { IInlineChatSessionService } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { IInlineChatService } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { getNotebookEditorFromEditorPane } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
Expand Down Expand Up @@ -53,12 +53,11 @@ export class EmptyCellEditorHintContribution extends EmptyTextEditorHintContribu
this.toDispose.push(activeEditor.onDidChangeActiveCell(() => this.update()));
}

protected override _shouldRenderHint(): boolean {
// TODO@rebornix, remove this when we have a better way to present the editor hints in empty cells
if (this.productService.quality === 'stable') {
return false;
}
protected override _getOptions(): IEmptyTextEditorHintOptions {
return { clickable: false };
}

protected override _shouldRenderHint(): boolean {
const shouldRenderHint = super._shouldRenderHint();
if (!shouldRenderHint) {
return false;
Expand Down