Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show results from hover providers incrementally #137714

Closed
alexdima opened this issue Nov 23, 2021 · 2 comments · Fixed by #137721
Closed

Show results from hover providers incrementally #137714

alexdima opened this issue Nov 23, 2021 · 2 comments · Fixed by #137721
Assignees
Labels
editor-hover Editor mouse hover feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@alexdima
Copy link
Member

alexdima commented Nov 23, 2021

When having multiple hover providers, it would be good to render results as soon as possible and not block on waiting for all hover providers. Sample:

  • package.json:
{
    "name": "137714",
    "publisher": "alex",
    "version": "0.0.1",
    "engines": {
        "vscode": "^1.22.0"
    },
    "activationEvents": ["*"],
    "main": "main.js"
}
  • main.js:
//@ts-check

const vscode = require("vscode");

/**
 *
 * @param {string} message
 * @param {number} timeout
 */
function createProvider(message, timeout) {
  return (
    /**
     * @param {import('vscode').TextDocument} document
     * @param {import('vscode').Position} position
     */
    function provideHover(document, position) {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve(new vscode.Hover(new vscode.MarkdownString(message)));
        }, timeout);
      });
    }
  );
}

/**
 * @param {string} message
 * @param {number} timeout
 */
function registerProvider(message, timeout) {
  const provideHover = createProvider(message, timeout);
  vscode.languages.registerHoverProvider({ language: 'typescript', }, { provideHover });
}

exports.activate = function (ctx) {
  registerProvider('Slow provider', 5000);
  registerProvider('Fast provider', 1000);
  registerProvider('Very fast provider', 0);
};
@alexdima alexdima added the editor-hover Editor mouse hover label Nov 23, 2021
@alexdima alexdima self-assigned this Nov 23, 2021
@alexdima alexdima added the feature-request Request for new features or functionality label Nov 23, 2021
@alexdima alexdima added this to the Backlog milestone Nov 23, 2021
@alexdima alexdima modified the milestones: Backlog, November 2021 Nov 23, 2021
@alexdima
Copy link
Member Author

BeforeAfter
Kapture.2021-11-23.at.23.33.03.mp4
Kapture.2021-11-23.at.23.35.00.mp4

@alexdima alexdima added the verification-needed Verification of issue is requested label Nov 30, 2021
@tanhakabir
Copy link
Contributor

Verification steps?

@tanhakabir tanhakabir added the verification-steps-needed Steps to verify are needed for verification label Nov 30, 2021
@jrieken jrieken added verified Verification succeeded and removed verification-steps-needed Steps to verify are needed for verification labels Dec 1, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-hover Editor mouse hover feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@jrieken @alexdima @tanhakabir and others