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

JavaScript Syntax Highlight: RegExp literals improperly parsed (persists from #349) #377

Closed
zrhmn opened this issue Dec 4, 2016 · 2 comments
Assignees
Labels

Comments

@zrhmn
Copy link

zrhmn commented Dec 4, 2016

TS and JS Grammar Extension version: latest

Code version: 1.7.2 (7ba55c5860b152d999dda59393ca3ebeb1b5c85f)

#349 (and microsoft/vscode#15051) was marked resolved and closed. I'm not really sure about how these fixes get to the monthly VSCode release, but at least one release (1.7.2) has been pushed since those issues were marked fixed. I added a comment to microsoft/vscode#15051 asking about when these fixes will be available in the release, but I guess nobody reads comments on closed issues.

The problem is, even in the latest release of VSCode this issue hasn't been fixed. I assumed that the latest version of TypeScript-TmLanguage did not make it to the 1.7.2 (which, again, I have no idea how that works). However, visiting this repo again, I noticed that the latest TypeScript-TmLanguage is also available as a VSCode extension... So I installed the VSCode extension. It would seem that the issue hasn't been fixed even in the latest release of the VSCode extension...

Here's a demo:

20161205024731_8765

@mhegazy mhegazy added the bug label Dec 5, 2016
@sheetalkamat sheetalkamat added the needs more info Needs additional information to be able to be able to take action on the issue label Dec 6, 2016
@sheetalkamat
Copy link
Member

@zia-newversion I am not able to repro this. Can you paste your code, may be it is little bit different from what has been fixed. Also please make sure the extension is updated to latest version. This is the what I see:
capture

@zrhmn
Copy link
Author

zrhmn commented Dec 7, 2016

@sheetalkamat You're correct. The snippet:

var v = (a / b).toString().match(/\d*(\.\d+)?/)

seem to be highlighted correctly. However, the code I was having an issue with was this:

module.exports = {
	responseTime,
	staticHeaders,
};

function responseTime() {
	return function* _responseTime(next) {
		let ti = process.hrtime();
		yield* next;

		let dt = process.hrtime(ti);
		dt = ((dt[0] * 1e9 + dt[1]) / 1e6).toFixed(3).replace(/\.?0+$/, '') + 'ms';

		this.set('X-Response-Time', dt);
		return;
	};
}

function staticHeaders(headers) {
	return function* _staticHeaders(next) {
		let hs = Object.keys(headers);
		if (hs.length)
			hs.forEach(h => this.set(h, headers[h]));

		return yield* next;
	};
}

Problem starts at line#12 of this snippet. However, note that if I move the RegExp literal to the next line somehow, e.g. like so:

		dt = ((dt[0] * 1e9 + dt[1]) / 1e6).toFixed(3)
			.replace(/\.?0+$/, '') + 'ms';

it's once again highlighted correctly. For the time being I have switched to the above as temporary solution, but there are a lot of other places in my code where it may not be syntactically or stylistically appropriate to break the line between the division operator and RegExp literal. Also, IMO that's not an appropriate fix for the issue, because the fix for syntax highlighting should not involve changes in the code-style.

Edit: Using v0.0.11 of the Latest TypeScript and Javascript Grammar package in VSCode (was using 0.0.10 when I created this issue, but another update was pushed since then and I installed that).

@sheetalkamat sheetalkamat removed the needs more info Needs additional information to be able to be able to take action on the issue label Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants