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

Expose a getter for model tokens #75

Closed
jefflevinson opened this issue Jul 19, 2016 · 1 comment
Closed

Expose a getter for model tokens #75

jefflevinson opened this issue Jul 19, 2016 · 1 comment
Labels
editor-api feature-request Request for new features or functionality
Milestone

Comments

@jefflevinson
Copy link

Originally, I was retrieving the data from the editor using this:
editor.getView().linesContent.children[3].children
where node [3] = div.view-lines
which gives a nicely structured list of tokens and data. However, my content got complicated enough that the content scrolled off of the view which is when I discovered it really only does give you what's in the view pane which wasn't obvious before. However, now I can't figure out how to get the data in the structured format for the non-visible portion of the editor. I've tried getModel and getView but it only comes back as raw text in those objects.

Thoughts?

@alexdima
Copy link
Member

There are "@internal" API methods that don't show up in the monaco.d.ts. e.g. https://github.com/Microsoft/vscode/blob/8d43ec51ac3123a379342fe1a4e9e63cefda57e6/src/vs/editor/common/editorCommon.ts#L1776

interface IModel { 
...
    /**
     * Tokenize if necessary and get the tokenization result for the line `lineNumber`, as returned by the language mode.
     * @internal
     */
    getLineContext(lineNumber:number): ILineContext;
...
}

/**
 * @internal
 */
export interface ILineContext {
    getLineContent(): string;

    modeTransitions: ModeTransition[];

    getTokenCount(): number;
    getTokenStartIndex(tokenIndex:number): number;
    getTokenType(tokenIndex:number): string;
    getTokenText(tokenIndex:number): string;
    getTokenEndIndex(tokenIndex:number): number;
    findIndexOfOffset(offset:number): number;
}

We are not ready to commit on the API shape in this area, that's why it is "hidden".

@alexdima alexdima added this to the Backlog milestone Aug 16, 2016
@alexdima alexdima self-assigned this Aug 16, 2016
@alexdima alexdima changed the title Processing the editor content Expose a getter for model tokens Jun 7, 2017
@alexdima alexdima added editor-api feature-request Request for new features or functionality and removed question labels Jun 7, 2017
@alexdima alexdima removed their assignment Jun 7, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-api feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

2 participants