mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-21 04:20:11 -04:00
Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)
* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 * fix pipelines * fix strict-null-checks * add missing files
This commit is contained in:
@@ -47,7 +47,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
|
||||
private readonly _domNode: HTMLDivElement;
|
||||
|
||||
private readonly _onClick = this._register(new Emitter<{ x: number; y: number; actions: CodeActionSet }>());
|
||||
private readonly _onClick = this._register(new Emitter<{ x: number; y: number; actions: CodeActionSet; }>());
|
||||
public readonly onClick = this._onClick.event;
|
||||
|
||||
private _state: LightBulbState.State = LightBulbState.Hidden;
|
||||
@@ -55,6 +55,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
constructor(
|
||||
private readonly _editor: ICodeEditor,
|
||||
private readonly _quickFixActionId: string,
|
||||
private readonly _preferredFixActionId: string,
|
||||
@IKeybindingService private readonly _keybindingService: IKeybindingService
|
||||
) {
|
||||
super();
|
||||
@@ -66,12 +67,12 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
this._register(this._editor.onDidChangeModelContent(_ => {
|
||||
// cancel when the line in question has been removed
|
||||
const editorModel = this._editor.getModel();
|
||||
if (this._state.type !== LightBulbState.Type.Showing || !editorModel || this._state.editorPosition.lineNumber >= editorModel.getLineCount()) {
|
||||
if (this.state.type !== LightBulbState.Type.Showing || !editorModel || this.state.editorPosition.lineNumber >= editorModel.getLineCount()) {
|
||||
this.hide();
|
||||
}
|
||||
}));
|
||||
this._register(dom.addStandardDisposableListener(this._domNode, 'mousedown', e => {
|
||||
if (this._state.type !== LightBulbState.Type.Showing) {
|
||||
if (this.state.type !== LightBulbState.Type.Showing) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -84,14 +85,14 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
const lineHeight = this._editor.getOption(EditorOption.lineHeight);
|
||||
|
||||
let pad = Math.floor(lineHeight / 3);
|
||||
if (this._state.widgetPosition.position !== null && this._state.widgetPosition.position.lineNumber < this._state.editorPosition.lineNumber) {
|
||||
if (this.state.widgetPosition.position !== null && this.state.widgetPosition.position.lineNumber < this.state.editorPosition.lineNumber) {
|
||||
pad += lineHeight;
|
||||
}
|
||||
|
||||
this._onClick.fire({
|
||||
x: e.posx,
|
||||
y: top + height + pad,
|
||||
actions: this._state.actions
|
||||
actions: this.state.actions
|
||||
});
|
||||
}));
|
||||
this._register(dom.addDisposableListener(this._domNode, 'mouseenter', (e: MouseEvent) => {
|
||||
@@ -173,7 +174,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
}
|
||||
}
|
||||
|
||||
this._state = new LightBulbState.Showing(actions, atPosition, {
|
||||
this.state = new LightBulbState.Showing(actions, atPosition, {
|
||||
position: { lineNumber: effectiveLineNumber, column: 1 },
|
||||
preference: LightBulbWidget._posPref
|
||||
});
|
||||
@@ -181,24 +182,37 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
this._editor.layoutContentWidget(this);
|
||||
}
|
||||
|
||||
private set title(value: string) {
|
||||
this._domNode.title = value;
|
||||
}
|
||||
|
||||
public hide(): void {
|
||||
this._state = LightBulbState.Hidden;
|
||||
this.state = LightBulbState.Hidden;
|
||||
this._editor.layoutContentWidget(this);
|
||||
}
|
||||
|
||||
private get state(): LightBulbState.State { return this._state; }
|
||||
|
||||
private set state(value) {
|
||||
this._state = value;
|
||||
this._updateLightBulbTitle();
|
||||
}
|
||||
|
||||
private _updateLightBulbTitle(): void {
|
||||
const kb = this._keybindingService.lookupKeybinding(this._quickFixActionId);
|
||||
let title: string;
|
||||
if (kb) {
|
||||
title = nls.localize('quickFixWithKb', "Show Fixes ({0})", kb.getLabel());
|
||||
} else {
|
||||
title = nls.localize('quickFix', "Show Fixes");
|
||||
if (this.state.type === LightBulbState.Type.Showing && this.state.actions.hasAutoFix) {
|
||||
const preferredKb = this._keybindingService.lookupKeybinding(this._preferredFixActionId);
|
||||
if (preferredKb) {
|
||||
this.title = nls.localize('prefferedQuickFixWithKb', "Show Fixes. Preferred Fix Available ({0})", preferredKb.getLabel());
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.title = title;
|
||||
|
||||
const kb = this._keybindingService.lookupKeybinding(this._quickFixActionId);
|
||||
if (kb) {
|
||||
this.title = nls.localize('quickFixWithKb', "Show Fixes ({0})", kb.getLabel());
|
||||
} else {
|
||||
this.title = nls.localize('quickFix', "Show Fixes");
|
||||
}
|
||||
}
|
||||
|
||||
private set title(value: string) {
|
||||
this._domNode.title = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user