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

Unexpected coloring of the token in the editor #1003

Open
aiday-mar opened this issue Aug 25, 2023 · 4 comments
Open

Unexpected coloring of the token in the editor #1003

aiday-mar opened this issue Aug 25, 2023 · 4 comments

Comments

@aiday-mar
Copy link

aiday-mar commented Aug 25, 2023

While examining code in the diff editor, I noticed that the color schema appears to be off. Notice how in the following image, the this token on line 322 is colored green while it should actually be a dark blue (like the other this tokens).

Screenshot 2023-08-25 at 14 22 40

I was using the following code:

Code

private _renderFoldingIconForLine(container: HTMLSpanElement, foldingModel: FoldingModel | null | undefined, index: number, line: number): FoldingIcon | undefined {
   const showFoldingControls: 'mouseover' | 'always' | 'never' = 
   this._editor.getOption(EditorOption.showFoldingControls);
   if (!foldingModel || showFoldingControls === 'never') {
      return;
   }
   const foldingRegions = foldingModel.regions;
   const indexOfFoldingRegion = foldingRegions.findRange(line);
   const startLineNumber = foldingRegions.getStartLineNumber(indexOfFoldingRegion);
   const isFoldingScope = line === startLineNumber;
   if (!isFoldingScope) {
      return;
   }
   const foldingIconNode = container.appendChild(document.createElement('div'));
   const isCollapsed = foldingRegions.isCollapsed(indexOfFoldingRegion);
   foldingIconNode.className = ThemeIcon.asClassName(isCollapsed ? foldingCollapsedIcon : foldingExpandedIcon);
   const foldingIcon = new FoldingIcon(foldingIconNode, isCollapsed);
   foldingIcon.setVisible(isCollapsed || showFoldingControls === 'always');
   foldingIcon.setTransitionRequired(true);

   this._foldingIconStore.add(dom.addDisposableListener(foldingIconNode, dom.EventType.CLICK, () => {
	toggleCollapseState(foldingModel, Number.MAX_VALUE, [line]);
	foldingIcon.isCollapsed = !isCollapsed;
	const scrollTop = (
		isCollapsed ?
			this._editor.getTopForLineNumber(startLineNumber)
			: this._editor.getTopForLineNumber(foldingRegions.getEndLineNumber(indexOfFoldingRegion)))
		- this._lineHeight * index + 1;
	this._editor.setScrollTop(scrollTop);
   }));
   return foldingIcon;
}

@aiday-mar
Copy link
Author

Hey @hediet, not sure if I should assign this to you? Feel free to change assignment.

@aiday-mar aiday-mar added the bug label Aug 25, 2023
@hediet
Copy link
Member

hediet commented Aug 25, 2023

Code_-_Insiders_U8h55dYcAo

When I add a whitespace after ? it works:

Code_-_Insiders_5rTL88WDav

globalThis.x = (
   globalThis ? 
   1 : foobar
);

@hediet hediet assigned mjbvz and unassigned hediet Aug 25, 2023
@aiday-mar
Copy link
Author

I see, the color schema is correct now too in the editor. I suppose that it had something to do with saving the document or formatting the document for the token colors to be rendered appropriately. I'll close the issue.

@hediet hediet reopened this Aug 25, 2023
@hediet
Copy link
Member

hediet commented Aug 25, 2023

I think this is indeed a bug of the typescript grammar!

@mjbvz mjbvz transferred this issue from microsoft/vscode Dec 6, 2023
@mjbvz mjbvz removed their assignment Dec 6, 2023
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

No branches or pull requests

3 participants