vscode#FoldingRangeKind TypeScript Examples

The following examples show how to use vscode#FoldingRangeKind. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FrontmatterFoldingRangeProvider.ts    From dendron with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
   * Returns the folding range of the frontmatter section of a markdown note.
   * @param document The document we want to find the folding range.
   * @returns The frontmatter folding range of given Dendron note as an array.
   */
  public async provideFoldingRanges(
    document: vscode.TextDocument
  ): Promise<vscode.FoldingRange[]> {
    try {
      const nodePosition = RemarkUtils.getNodePositionPastFrontmatter(
        document.getText()
      );
      const range =
        nodePosition !== undefined
          ? new vscode.FoldingRange(
              VSCodeUtils.point2VSCodePosition(nodePosition.start).line,
              VSCodeUtils.point2VSCodePosition(nodePosition.end).line,
              FoldingRangeKind.Region
            )
          : undefined;
      if (_.isUndefined(range)) return [];
      return [range];
    } catch (error) {
      Sentry.captureException(error);
      throw error;
    }
  }