mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
This reverts commit d15a3fcc98.
This commit is contained in:
@@ -7,7 +7,7 @@ import 'vs/css!./hover';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget';
|
||||
import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, ServicesAccessor, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
@@ -34,7 +34,7 @@ export class ModesHoverController implements IEditorContribution {
|
||||
|
||||
private static readonly ID = 'editor.contrib.hover';
|
||||
|
||||
private readonly _toUnhook = new DisposableStore();
|
||||
private _toUnhook: IDisposable[];
|
||||
private readonly _didChangeConfigurationHandler: IDisposable;
|
||||
|
||||
private _contentWidget: ModesContentHoverWidget;
|
||||
@@ -73,6 +73,8 @@ export class ModesHoverController implements IEditorContribution {
|
||||
@ICommandService private readonly _commandService: ICommandService,
|
||||
@IThemeService private readonly _themeService: IThemeService
|
||||
) {
|
||||
this._toUnhook = [];
|
||||
|
||||
this._isMouseDown = false;
|
||||
this._hoverClicked = false;
|
||||
|
||||
@@ -94,22 +96,22 @@ export class ModesHoverController implements IEditorContribution {
|
||||
this._isHoverEnabled = hoverOpts.enabled;
|
||||
this._isHoverSticky = hoverOpts.sticky;
|
||||
if (this._isHoverEnabled) {
|
||||
this._toUnhook.add(this._editor.onMouseDown((e: IEditorMouseEvent) => this._onEditorMouseDown(e)));
|
||||
this._toUnhook.add(this._editor.onMouseUp((e: IEditorMouseEvent) => this._onEditorMouseUp(e)));
|
||||
this._toUnhook.add(this._editor.onMouseMove((e: IEditorMouseEvent) => this._onEditorMouseMove(e)));
|
||||
this._toUnhook.add(this._editor.onKeyDown((e: IKeyboardEvent) => this._onKeyDown(e)));
|
||||
this._toUnhook.add(this._editor.onDidChangeModelDecorations(() => this._onModelDecorationsChanged()));
|
||||
this._toUnhook.push(this._editor.onMouseDown((e: IEditorMouseEvent) => this._onEditorMouseDown(e)));
|
||||
this._toUnhook.push(this._editor.onMouseUp((e: IEditorMouseEvent) => this._onEditorMouseUp(e)));
|
||||
this._toUnhook.push(this._editor.onMouseMove((e: IEditorMouseEvent) => this._onEditorMouseMove(e)));
|
||||
this._toUnhook.push(this._editor.onKeyDown((e: IKeyboardEvent) => this._onKeyDown(e)));
|
||||
this._toUnhook.push(this._editor.onDidChangeModelDecorations(() => this._onModelDecorationsChanged()));
|
||||
} else {
|
||||
this._toUnhook.add(this._editor.onMouseMove(hideWidgetsEventHandler));
|
||||
this._toUnhook.push(this._editor.onMouseMove(hideWidgetsEventHandler));
|
||||
}
|
||||
|
||||
this._toUnhook.add(this._editor.onMouseLeave(hideWidgetsEventHandler));
|
||||
this._toUnhook.add(this._editor.onDidChangeModel(hideWidgetsEventHandler));
|
||||
this._toUnhook.add(this._editor.onDidScrollChange((e: IScrollEvent) => this._onEditorScrollChanged(e)));
|
||||
this._toUnhook.push(this._editor.onMouseLeave(hideWidgetsEventHandler));
|
||||
this._toUnhook.push(this._editor.onDidChangeModel(hideWidgetsEventHandler));
|
||||
this._toUnhook.push(this._editor.onDidScrollChange((e: IScrollEvent) => this._onEditorScrollChanged(e)));
|
||||
}
|
||||
|
||||
private _unhookEvents(): void {
|
||||
this._toUnhook.clear();
|
||||
this._toUnhook = dispose(this._toUnhook);
|
||||
}
|
||||
|
||||
private _onModelDecorationsChanged(): void {
|
||||
@@ -225,7 +227,6 @@ export class ModesHoverController implements IEditorContribution {
|
||||
|
||||
public dispose(): void {
|
||||
this._unhookEvents();
|
||||
this._toUnhook.dispose();
|
||||
this._didChangeConfigurationHandler.dispose();
|
||||
|
||||
if (this._glyphWidget) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { Widget } from 'vs/base/browser/ui/widget';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
|
||||
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
@@ -24,6 +25,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
|
||||
protected _showAtRange: Range | null;
|
||||
private _stoleFocus: boolean;
|
||||
private readonly scrollbar: DomScrollableElement;
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
// Editor.IContentWidget.allowEditorOverflow
|
||||
public allowEditorOverflow = true;
|
||||
@@ -51,7 +53,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
|
||||
this._domNode.className = 'monaco-editor-hover-content';
|
||||
|
||||
this.scrollbar = new DomScrollableElement(this._domNode, {});
|
||||
this._register(this.scrollbar);
|
||||
this.disposables.push(this.scrollbar);
|
||||
this._containerDomNode.appendChild(this.scrollbar.getDomNode());
|
||||
|
||||
this.onkeydown(this._containerDomNode, (e: IKeyboardEvent) => {
|
||||
@@ -127,6 +129,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
|
||||
|
||||
public dispose(): void {
|
||||
this._editor.removeContentWidget(this);
|
||||
this.disposables = dispose(this.disposables);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as dom from 'vs/base/browser/dom';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Color, RGBA } from 'vs/base/common/color';
|
||||
import { IMarkdownString, MarkdownString, isEmptyMarkdownString, markedStringsEquals } from 'vs/base/common/htmlContent';
|
||||
import { Disposable, IDisposable, toDisposable, DisposableStore, combinedDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, IDisposable, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
@@ -187,10 +187,6 @@ class ModesContentComputer implements IHoverComputer<HoverPart[]> {
|
||||
}
|
||||
}
|
||||
|
||||
interface ActionSet extends IDisposable {
|
||||
readonly actions: Action[];
|
||||
}
|
||||
|
||||
export class ModesContentHoverWidget extends ContentHoverWidget {
|
||||
|
||||
static readonly ID = 'editor.contrib.modesContentHoverWidget';
|
||||
@@ -440,7 +436,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
||||
this.updateContents(fragment);
|
||||
this._colorPicker.layout();
|
||||
|
||||
this.renderDisposable = combinedDisposable(colorListener, colorChangeListener, widget, ...markdownDisposeables);
|
||||
this.renderDisposable = combinedDisposable([colorListener, colorChangeListener, widget, ...markdownDisposeables]);
|
||||
});
|
||||
} else {
|
||||
if (msg instanceof MarkerHover) {
|
||||
@@ -530,25 +526,24 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
||||
|
||||
private renderMarkerStatusbar(markerHover: MarkerHover): HTMLElement {
|
||||
const hoverElement = $('div.hover-row.status-bar');
|
||||
const disposables = new DisposableStore();
|
||||
const disposables: IDisposable[] = [];
|
||||
const actionsElement = dom.append(hoverElement, $('div.actions'));
|
||||
disposables.add(this.renderAction(actionsElement, {
|
||||
disposables.push(this.renderAction(actionsElement, {
|
||||
label: nls.localize('quick fixes', "Quick Fix..."),
|
||||
commandId: QuickFixAction.Id,
|
||||
run: async (target) => {
|
||||
const codeActionsPromise = this.getCodeActions(markerHover.marker);
|
||||
disposables.add(toDisposable(() => codeActionsPromise.cancel()));
|
||||
disposables.push(toDisposable(() => codeActionsPromise.cancel()));
|
||||
const actions = await codeActionsPromise;
|
||||
disposables.add(actions);
|
||||
const elementPosition = dom.getDomNodePagePosition(target);
|
||||
this._contextMenuService.showContextMenu({
|
||||
getAnchor: () => ({ x: elementPosition.left + 6, y: elementPosition.top + elementPosition.height + 6 }),
|
||||
getActions: () => actions.actions
|
||||
getActions: () => actions
|
||||
});
|
||||
}
|
||||
}));
|
||||
if (markerHover.marker.severity === MarkerSeverity.Error || markerHover.marker.severity === MarkerSeverity.Warning || markerHover.marker.severity === MarkerSeverity.Info) {
|
||||
disposables.add(this.renderAction(actionsElement, {
|
||||
disposables.push(this.renderAction(actionsElement, {
|
||||
label: nls.localize('peek problem', "Peek Problem"),
|
||||
commandId: NextMarkerAction.ID,
|
||||
run: () => {
|
||||
@@ -558,37 +553,24 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
||||
}
|
||||
}));
|
||||
}
|
||||
this.renderDisposable = disposables;
|
||||
this.renderDisposable = combinedDisposable(disposables);
|
||||
return hoverElement;
|
||||
}
|
||||
|
||||
private getCodeActions(marker: IMarker): CancelablePromise<ActionSet> {
|
||||
private getCodeActions(marker: IMarker): CancelablePromise<Action[]> {
|
||||
return createCancelablePromise(async cancellationToken => {
|
||||
const codeActions = await getCodeActions(this._editor.getModel()!, new Range(marker.startLineNumber, marker.startColumn, marker.endLineNumber, marker.endColumn), { type: 'manual', filter: { kind: CodeActionKind.QuickFix } }, cancellationToken);
|
||||
if (codeActions.actions.length) {
|
||||
const disposables = new DisposableStore();
|
||||
const actions: Action[] = [];
|
||||
for (const codeAction of codeActions.actions) {
|
||||
disposables.add(disposables);
|
||||
actions.push(new Action(
|
||||
codeAction.command ? codeAction.command.id : codeAction.title,
|
||||
codeAction.title,
|
||||
undefined,
|
||||
true,
|
||||
() => applyCodeAction(codeAction, this._bulkEditService, this._commandService)));
|
||||
}
|
||||
return {
|
||||
actions: actions,
|
||||
dispose: () => disposables.dispose()
|
||||
};
|
||||
return codeActions.actions.map(codeAction => new Action(
|
||||
codeAction.command ? codeAction.command.id : codeAction.title,
|
||||
codeAction.title,
|
||||
undefined,
|
||||
true,
|
||||
() => applyCodeAction(codeAction, this._bulkEditService, this._commandService)));
|
||||
}
|
||||
|
||||
return {
|
||||
actions: [
|
||||
new Action('', nls.localize('editor.action.quickFix.noneMessage', "No code actions available"))
|
||||
],
|
||||
dispose() { }
|
||||
};
|
||||
return [
|
||||
new Action('', nls.localize('editor.action.quickFix.noneMessage', "No code actions available"))
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user