Johannes Rieken
2022-10-14 17:51:16 +02:00
committed by GitHub
parent a2ecf38136
commit ee0b7792a1
3 changed files with 13 additions and 8 deletions
@@ -25,11 +25,15 @@ export class ClickLinkMouseEvent {
public readonly hasTriggerModifier: boolean;
public readonly hasSideBySideModifier: boolean;
public readonly isNoneOrSingleMouseDown: boolean;
public readonly hasRightClick: boolean;
public readonly isLeftClick: boolean;
public readonly isMiddleClick: boolean;
public readonly isRightClick: boolean;
constructor(source: IEditorMouseEvent, opts: ClickLinkOptions) {
this.target = source.target;
this.hasRightClick = source.event.rightButton;
this.isLeftClick = source.event.leftButton;
this.isMiddleClick = source.event.middleButton;
this.isRightClick = source.event.rightButton;
this.hasTriggerModifier = hasModifier(source.event, opts.triggerModifier);
this.hasSideBySideModifier = hasModifier(source.event, opts.triggerSideBySideModifier);
this.isNoneOrSingleMouseDown = (source.event.detail <= 1);
@@ -277,11 +277,12 @@ export class GotoDefinitionAtPositionEditorContribution implements IEditorContri
}
private isEnabled(mouseEvent: ClickLinkMouseEvent, withKey?: ClickLinkKeyboardEvent): boolean {
return this.editor.hasModel() &&
mouseEvent.isNoneOrSingleMouseDown &&
(mouseEvent.target.type === MouseTargetType.CONTENT_TEXT) &&
(mouseEvent.hasTriggerModifier || (withKey ? withKey.keyCodeIsTriggerKey : false)) &&
this.languageFeaturesService.definitionProvider.has(this.editor.getModel());
return this.editor.hasModel()
&& mouseEvent.isLeftClick
&& mouseEvent.isNoneOrSingleMouseDown
&& mouseEvent.target.type === MouseTargetType.CONTENT_TEXT
&& (mouseEvent.hasTriggerModifier || (withKey ? withKey.keyCodeIsTriggerKey : false))
&& this.languageFeaturesService.definitionProvider.has(this.editor.getModel());
}
private findDefinition(position: Position, token: CancellationToken): Promise<LocationLink[] | null> {
@@ -152,7 +152,7 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
this._editor.revealPosition({ lineNumber: this._hoverOnLine, column: 1 });
}
this._instaService.invokeFunction(goToDefinitionWithLocation, e, this._editor as IActiveCodeEditor, { uri: this._editor.getModel()!.uri, range: this._stickyRangeProjectedOnEditor } as Location);
} else if (!e.hasRightClick) {
} else if (!e.isRightClick) {
// Normal click
this._editor.revealPosition({ lineNumber: this._hoverOnLine, column: 1 });
}