visual-studio-codevscode-extensionscodelens

How I can filter lens inside resolveCodeLens?


I am trying to split CodeLensProvider implementation in two parts. First part is implementation of provideCodeLenses which returns array of unresolved CodeLens. And the second part is implementation of resolveCodeLens.

So I want to ignore some kind of CodeLens don't match some conditions inside resolveCodeLens because provideCodeLenses should return as fast as possible. Is it possible to do?

Right now I just got <<MISSING COMMAND>> for unresolved CodeLens.

An Example

class Provider implements CodeLensProvider {
  provideCodeLenses() {
    return [lensA, lensB, lensC];
  }

  resolveCodeLens(lens) {
    return executeCommand('vscode.someCommand')
      .then((result) => {
        if (result.isTrue) {
          return lens.resolve();
        } else {
          // ignore `lens`
        }
      });
  }
}

Solution

  • Well. According to the answer on the VSCode repository, this is not possible to do. :(