fix: add more changes

This commit is contained in:
helmisek 2024-09-19 02:02:05 +02:00
parent 7e746b4fd6
commit b07fbd627a
No known key found for this signature in database
GPG key ID: 5DAEE2C2E5B20A63
5 changed files with 26 additions and 17 deletions

View file

@ -222,7 +222,7 @@ export class HoverWidget extends Widget implements IHoverWidget {
}
// Show the hover hint if needed
if (hideOnHover && options.appearance?.showHoverHint) {
if (options.appearance?.showHoverHint) {
const statusBarElement = $('div.hover-row.status-bar');
const infoElement = $('div.info');
infoElement.textContent = localize('hoverhint', 'Hold {0} key to mouse over', isMacintosh ? 'Option' : 'Alt');

View file

@ -2019,9 +2019,9 @@ export interface CommentThreadChangedEvent<T> {
}
export interface CodeLens {
range: IRange; // the range of code
id?: string; // no idea what this is for
command?: Command; // command to run when they click the codeLens
range: IRange;
id?: string;
command?: Command;
}
export interface CodeLensList {

View file

@ -180,6 +180,12 @@ export class CodeActionController extends Disposable implements IEditorContribut
return;
}
const selection = this._editor.getSelection();
if (selection?.startLineNumber !== newState.position.lineNumber) {
return;
}
this._lightBulbWidget.value?.update(actions, newState.trigger, newState.position);
if (newState.trigger.type === CodeActionTriggerType.Invoke) {

View file

@ -75,6 +75,14 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
private _gutterState: LightBulbState.State = LightBulbState.Hidden;
private _iconClasses: string[] = [];
private readonly lightbulbClasses = [
'codicon-' + GUTTER_LIGHTBULB_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AIFIX_AUTO_FIX_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AUTO_FIX_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AIFIX_ICON.id,
'codicon-' + GUTTER_SPARKLE_FILLED_ICON.id
];
private _preferredKbLabel?: string;
private _quickFixKbLabel?: string;
@ -148,15 +156,8 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
}));
this._register(this._editor.onMouseDown(async (e: IEditorMouseEvent) => {
const lightbulbClasses = [
'codicon-' + GUTTER_LIGHTBULB_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AIFIX_AUTO_FIX_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AUTO_FIX_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AIFIX_ICON.id,
'codicon-' + GUTTER_SPARKLE_FILLED_ICON.id
];
if (!e.target.element || !lightbulbClasses.some(cls => e.target.element && e.target.element.classList.contains(cls))) {
if (!e.target.element || !this.lightbulbClasses.some(cls => e.target.element && e.target.element.classList.contains(cls))) {
return;
}
@ -247,7 +248,9 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
let hasDecoration = false;
if (currLineDecorations) {
for (const decoration of currLineDecorations) {
if (decoration.options.glyphMarginClassName) {
const glyphClass = decoration.options.glyphMarginClassName;
if (glyphClass && !this.lightbulbClasses.some(className => glyphClass.includes(className))) {
hasDecoration = true;
break;
}
@ -271,7 +274,6 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
const currLineEmptyOrIndented = isLineEmptyOrIndented(lineNumber);
const notEmpty = !nextLineEmptyOrIndented && !prevLineEmptyOrIndented;
// check above and below. if both are blocked, display lightbulb in the gutter.
if (!nextLineEmptyOrIndented && !prevLineEmptyOrIndented && !hasDecoration) {
this.gutterState = new LightBulbState.Showing(actions, trigger, atPosition, {
@ -280,7 +282,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
});
this.renderGutterLightbub();
return this.hide();
} else if (prevLineEmptyOrIndented || endLine || (notEmpty && !currLineEmptyOrIndented)) {
} else if (prevLineEmptyOrIndented || endLine || (prevLineEmptyOrIndented && !currLineEmptyOrIndented)) {
effectiveLineNumber -= 1;
} else if (nextLineEmptyOrIndented || (notEmpty && currLineEmptyOrIndented)) {
effectiveLineNumber += 1;

View file

@ -318,7 +318,8 @@ export class RenameWidget implements IRenameWidget, IContentWidget, IDisposable
}
afterRender(position: ContentWidgetPositionPreference | null): void {
this._trace('invoking afterRender, position: ', position ? 'not null' : 'null');
// FIXME@ulugbekna: commenting trace log out until we start unmounting the widget from editor properly - https://github.com/microsoft/vscode/issues/226975
// this._trace('invoking afterRender, position: ', position ? 'not null' : 'null');
if (position === null) {
// cancel rename when input widget isn't rendered anymore
this.cancelInput(true, 'afterRender (because position is null)');
@ -363,7 +364,7 @@ export class RenameWidget implements IRenameWidget, IContentWidget, IDisposable
}
cancelInput(focusEditor: boolean, caller: string): void {
this._trace(`invoking cancelInput, caller: ${caller}, _currentCancelInput: ${this._currentAcceptInput ? 'not undefined' : 'undefined'}`);
// this._trace(`invoking cancelInput, caller: ${caller}, _currentCancelInput: ${this._currentAcceptInput ? 'not undefined' : 'undefined'}`);
this._currentCancelInput?.(focusEditor);
}