Skip to content

Commit

Permalink
Merge pull request #35 from mkslanc/hover-fold-bug
Browse files Browse the repository at this point in the history
fixed bug for hover while folded
  • Loading branch information
mkslanc authored Feb 1, 2023
2 parents fba48d7 + baef4c8 commit ffedc43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
17 changes: 7 additions & 10 deletions packages/ace-linters/components/description-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,22 @@ export class DescriptionTooltip extends Tooltip {

doHover = () => {
let renderer = this.$activeEditor.renderer;
let screenPos = renderer.pixelToScreenCoordinates(this.x, this.y);
let screenCoordinates = renderer.pixelToScreenCoordinates(this.x, this.y);

let session = this.$activeEditor.session;
let docPos = session.screenToDocumentPosition(screenCoordinates.row, screenCoordinates.column);

this.provider.doHover(session, screenPos, (hover) => {
if (!hover)
return;
let description = this.provider.getTooltipText(hover);
if (!description || !description.text) {
this.provider.doHover(session, docPos, (hover) => {
let descriptionText = hover ? this.provider.getTooltipText(hover) : null;
if (!hover || !descriptionText) {
this.hide();
return;
}
let descriptionText = description.text;

let docPos = session.screenToDocumentPosition(screenPos.row, screenPos.column);
let token = session.getTokenAt(docPos.row, docPos.column + 1);

let row = description.range?.start.row ?? docPos.row;
let column = description.range?.start.column ?? token?.start ?? 0;
let row = hover.range?.start.row ?? docPos.row;
let column = hover.range?.start.column ?? token?.start ?? 0;

if (this.descriptionText != descriptionText) {
this.hide();
Expand Down
7 changes: 2 additions & 5 deletions packages/ace-linters/language-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,9 @@ export class LanguageProvider {
this.$messageController.doHover(this.$getFileName(session), fromPoint(position), (hover) => callback && callback(toTooltip(hover)));
}

getTooltipText(hover: Tooltip) {
if (!hover)
return;
let text = hover.content.type === CommonConverter.TooltipType.markdown ?
getTooltipText(hover: Tooltip): string | undefined {
return hover.content.type === CommonConverter.TooltipType.markdown ?
CommonConverter.cleanHtml(this.$markdownConverter.makeHtml(hover.content.text)) : hover.content.text;
return {text: text, range: hover.range}
}

format = () => {
Expand Down

0 comments on commit ffedc43

Please sign in to comment.