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 // Show the hover hint if needed
if (hideOnHover && options.appearance?.showHoverHint) { if (options.appearance?.showHoverHint) {
const statusBarElement = $('div.hover-row.status-bar'); const statusBarElement = $('div.hover-row.status-bar');
const infoElement = $('div.info'); const infoElement = $('div.info');
infoElement.textContent = localize('hoverhint', 'Hold {0} key to mouse over', isMacintosh ? 'Option' : 'Alt'); 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 { export interface CodeLens {
range: IRange; // the range of code range: IRange;
id?: string; // no idea what this is for id?: string;
command?: Command; // command to run when they click the codeLens command?: Command;
} }
export interface CodeLensList { export interface CodeLensList {

View file

@ -180,6 +180,12 @@ export class CodeActionController extends Disposable implements IEditorContribut
return; return;
} }
const selection = this._editor.getSelection();
if (selection?.startLineNumber !== newState.position.lineNumber) {
return;
}
this._lightBulbWidget.value?.update(actions, newState.trigger, newState.position); this._lightBulbWidget.value?.update(actions, newState.trigger, newState.position);
if (newState.trigger.type === CodeActionTriggerType.Invoke) { 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 _gutterState: LightBulbState.State = LightBulbState.Hidden;
private _iconClasses: string[] = []; 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 _preferredKbLabel?: string;
private _quickFixKbLabel?: string; private _quickFixKbLabel?: string;
@ -148,15 +156,8 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
})); }));
this._register(this._editor.onMouseDown(async (e: IEditorMouseEvent) => { 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; return;
} }
@ -247,7 +248,9 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
let hasDecoration = false; let hasDecoration = false;
if (currLineDecorations) { if (currLineDecorations) {
for (const decoration of 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; hasDecoration = true;
break; break;
} }
@ -271,7 +274,6 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
const currLineEmptyOrIndented = isLineEmptyOrIndented(lineNumber); const currLineEmptyOrIndented = isLineEmptyOrIndented(lineNumber);
const notEmpty = !nextLineEmptyOrIndented && !prevLineEmptyOrIndented; const notEmpty = !nextLineEmptyOrIndented && !prevLineEmptyOrIndented;
// check above and below. if both are blocked, display lightbulb in the gutter. // check above and below. if both are blocked, display lightbulb in the gutter.
if (!nextLineEmptyOrIndented && !prevLineEmptyOrIndented && !hasDecoration) { if (!nextLineEmptyOrIndented && !prevLineEmptyOrIndented && !hasDecoration) {
this.gutterState = new LightBulbState.Showing(actions, trigger, atPosition, { this.gutterState = new LightBulbState.Showing(actions, trigger, atPosition, {
@ -280,7 +282,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
}); });
this.renderGutterLightbub(); this.renderGutterLightbub();
return this.hide(); return this.hide();
} else if (prevLineEmptyOrIndented || endLine || (notEmpty && !currLineEmptyOrIndented)) { } else if (prevLineEmptyOrIndented || endLine || (prevLineEmptyOrIndented && !currLineEmptyOrIndented)) {
effectiveLineNumber -= 1; effectiveLineNumber -= 1;
} else if (nextLineEmptyOrIndented || (notEmpty && currLineEmptyOrIndented)) { } else if (nextLineEmptyOrIndented || (notEmpty && currLineEmptyOrIndented)) {
effectiveLineNumber += 1; effectiveLineNumber += 1;

View file

@ -318,7 +318,8 @@ export class RenameWidget implements IRenameWidget, IContentWidget, IDisposable
} }
afterRender(position: ContentWidgetPositionPreference | null): void { 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) { if (position === null) {
// cancel rename when input widget isn't rendered anymore // cancel rename when input widget isn't rendered anymore
this.cancelInput(true, 'afterRender (because position is null)'); 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 { 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); this._currentCancelInput?.(focusEditor);
} }