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

allow leading space for bs:disable comments #108

Merged
merged 9 commits into from
Jun 9, 2020

Conversation

TwitchBronBron
Copy link
Member

Currently the bs:disable-line and bs:disable-next-line comments do not support leading spaces. There's no reason not to, so this PR fixes that.

@@ -121,16 +121,13 @@ export class BrsFile {
throw new Error(`File was already processed. Create a new instance of BrsFile instead. ${this.pathAbsolute}`);
}

//split the text into lines
let lines = util.getLines(fileContents);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice benefit, we no longer need to split the file contents by line and process it, since getIgnores works on the list of tokens now.

/**
* Small tokenizer for bs:disable comments
*/
public tokenizeBsDisableComment(token: Token) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple little tokenizer/parser function that makes dealing with disable comments easier.

if (tokenized.disableType === 'line') {
affectedRange = Range.create(token.range.start.line, 0, token.range.start.line, token.range.start.character);
} else if (tokenized.disableType === 'next-line') {
affectedRange = Range.create(token.range.start.line + 1, 0, token.range.start.line + 1, Number.MAX_SAFE_INTEGER);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to find the length of the next line, but there's no real benefit to doing that, so just use MAX_SAFE_INTEGER instead because that will definitely match anything on the next line.

@TwitchBronBron TwitchBronBron merged commit 7d4309b into master Jun 9, 2020
@TwitchBronBron TwitchBronBron deleted the leading-space-comments branch June 9, 2020 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant