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

Support for FontStyle.Strikethrough (tracking issue) #158

Closed
ghost opened this issue Dec 11, 2021 · 3 comments · Fixed by #159
Closed

Support for FontStyle.Strikethrough (tracking issue) #158

ghost opened this issue Dec 11, 2021 · 3 comments · Fixed by #159
Labels
feature-request Request for new features or functionality
Milestone

Comments

@ghost
Copy link

ghost commented Dec 11, 2021

Just a note for anyone looking into this: for text grammars, it seems that adding an extra font-style will not play nicely with the current binary format we use for tokens

Such a change needs to begin in the project vscode-textmate. The bit encoding format for tokens is defined in that project at:

vscode-textmate/src/main.ts

Lines 201 to 233 in a53ae3c

/**
* Helpers to manage the "collapsed" metadata of an entire StackElement stack.
* The following assumptions have been made:
* - languageId < 256 => needs 8 bits
* - unique color count < 512 => needs 9 bits
*
* The binary format is:
* - -------------------------------------------
* 3322 2222 2222 1111 1111 1100 0000 0000
* 1098 7654 3210 9876 5432 1098 7654 3210
* - -------------------------------------------
* xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
* bbbb bbbb bfff ffff ffFF FTTT LLLL LLLL
* - -------------------------------------------
* - L = LanguageId (8 bits)
* - T = StandardTokenType (3 bits)
* - F = FontStyle (3 bits)
* - f = foreground color (9 bits)
* - b = background color (9 bits)
*/
export const enum MetadataConsts {
LANGUAGEID_MASK = 0b00000000000000000000000011111111,
TOKEN_TYPE_MASK = 0b00000000000000000000011100000000,
FONT_STYLE_MASK = 0b00000000000000000011100000000000,
FOREGROUND_MASK = 0b00000000011111111100000000000000,
BACKGROUND_MASK = 0b11111111100000000000000000000000,
LANGUAGEID_OFFSET = 0,
TOKEN_TYPE_OFFSET = 8,
FONT_STYLE_OFFSET = 11,
FOREGROUND_OFFSET = 14,
BACKGROUND_OFFSET = 23
}

Adding the strikethrough font style would require four bits instead of three

Once that project has a new token bit encoding format, it needs to be published with a new major version (since this is a breaking change) and then adopted in VS Code.

Also, the enums are powers of 2 because they represent bits, so FontStyle.Strikethrough would be 8. But for it to be 8, then all the other information bits need to be shifted by 1.

@alexdima
Copy link
Member

To make room for it, I think StandardTokenType could be shrinked to only 2 bits (it has only 4 possible values: Other, Comment, String, RegEx and they don't need to be masks).

@alexdima alexdima added the feature-request Request for new features or functionality label Dec 13, 2021
@ghost
Copy link
Author

ghost commented Dec 13, 2021

Awesome! Normally I would start work on this immediately but I have to port my Textmate LSP to the browser and its a rather involved task because of the moving parts. I could get to this in the New Year? 🤔

@ghost
Copy link
Author

ghost commented Dec 16, 2021

Draft PR at #159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant