Skip to content

Fix problems that can occur when we can't find the theme json#5177

Merged
rchiodo merged 13 commits into
masterfrom
rchiodo/fix_unknowntheme
Apr 10, 2019
Merged

Fix problems that can occur when we can't find the theme json#5177
rchiodo merged 13 commits into
masterfrom
rchiodo/fix_unknowntheme

Conversation

@rchiodo
Copy link
Copy Markdown

@rchiodo rchiodo commented Apr 9, 2019

For #5136

Modify our react code to have a 'StyleInjector' that pulls our css values from the extension instead of having the extension generate them on startup. This is necessary because in the non theme case, we can't tell if we're dark or light. However VS Code knows and will tell us.

When no json is found we use the 'vscode-light' or 'vscode-dark' to decide on a base theme.

This has the side effect of also making our window update when the user updates the theme. No more reopening the window.

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Has a news entry file (remember to thank yourself!)
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated
  • Test plan is updated as appropriate
  • package-lock.json has been regenerated by running npm install (if dependencies have changed)
  • The wiki is updated with any design decisions/details.

@rchiodo rchiodo self-assigned this Apr 9, 2019
@rchiodo rchiodo requested a review from IanMatthewHuff April 9, 2019 18:05

@injectable()
export class DataViewer implements IDataViewer, IAsyncDisposable {
export class DataViewer extends WebViewHost<IDataViewerMapping> implements IDataViewer, IDisposable {
Copy link
Copy Markdown
Author

@rchiodo rchiodo Apr 9, 2019

Choose a reason for hiding this comment

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

WebViewHost [](start = 32, length = 11)

History and DataViewer now derive from the WebViewHost. This simplifies the css handling and other common stuff (like putting up the webview) #Resolved

export declare function acquireVsCodeApi(): IVsCodeApi;

// tslint:disable-next-line: no-unnecessary-class
export class PostOffice {
Copy link
Copy Markdown
Author

@rchiodo rchiodo Apr 9, 2019

Choose a reason for hiding this comment

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

PostOffice [](start = 13, length = 10)

I changed this class to be static. Otherwise I was passing refs to components around (the styleInjector needs a post office too). Seems like it didn't need to be a component at all as it doesn't render anything. #Resolved

this.wrapper = undefined;
}

PostOffice.resetApi();
Copy link
Copy Markdown
Author

@rchiodo rchiodo Apr 9, 2019

Choose a reason for hiding this comment

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

PostOffice [](start = 8, length = 10)

Because the postoffice isn't a component anymore, we need to cleanup after every test. #Resolved

Comment thread news/2 Fixes/5136.md
@@ -0,0 +1,2 @@
Default colors when theme.json cannot be found.
Fix python interactive window to update when theme changes. No newline at end of file
Copy link
Copy Markdown
Member

@IanMatthewHuff IanMatthewHuff Apr 10, 2019

Choose a reason for hiding this comment

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

This seems like a good candidate for a manual test case in our CTI test plan file. #Resolved

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I agree. Is that in our source somewhere? I can update it here.


In reply to: 274056601 [](ancestors = 274056601)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yup. .github/test_plan.md


In reply to: 274056754 [](ancestors = 274056754,274056601)

const theme = ignoreTheme ? DefaultTheme : workbench.get<string>('colorTheme');
const terminalCursor = workbench.get<string>('terminal.integrated.cursorStyle', 'block');
theme = ignoreTheme ? DefaultTheme : theme;
const terminalCursor = workbench ? workbench.get<string>('terminal.integrated.cursorStyle', 'block') : 'block';
Copy link
Copy Markdown
Member

@IanMatthewHuff IanMatthewHuff Apr 10, 2019

Choose a reason for hiding this comment

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

Not directly part of this checkin, but the default for cursorStyle for VSCode is line, not block. #ByDesign

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That's not what my settings say.


In reply to: 274059636 [](ancestors = 274059636)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Maybe you're thinking of editor cursor? Not terminal cursor?


In reply to: 274060268 [](ancestors = 274060268,274059636)

css = this.generateCss(theme, tokenColors, font, fontSize, terminalCursor, ignoreTheme ? LightTheme : undefined);
} else if (tokenColors === null && font && fontSize) {
// No colors found. See if we can figure out what type of theme we have
const style = (theme && isDark) ? DarkTheme : LightTheme ;
Copy link
Copy Markdown
Member

@IanMatthewHuff IanMatthewHuff Apr 10, 2019

Choose a reason for hiding this comment

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

we are already inside a if(theme) block here #Resolved

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh yeah. True.


In reply to: 274060589 [](ancestors = 274060589)

}

private getScopeStyle = (tokenColors: JSONArray, scope: string, secondary?: string): { color: string; fontStyle: string } => {
private getScopeStyle = (tokenColors: JSONArray | null, scope: string, secondary: string, defaultStyle: string | undefined): { color: string; fontStyle: string } => {
Copy link
Copy Markdown
Member

@IanMatthewHuff IanMatthewHuff Apr 10, 2019

Choose a reason for hiding this comment

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

More of a style issue, but for X | undefined I'd usually just use ? notation, especially as a parameter. #ByDesign

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

There's a difference though. x? notation means the caller doesn't have to send that parameter. X | undefined means they have to be explicit. This change was to force it to be explicit.


In reply to: 274062994 [](ancestors = 274062994)

Comment thread src/client/datascience/webViewHost.ts Outdated

// Post a message to our webpanel and update our new datascience settings
private onPossibleThemeChange = (event: ConfigurationChangeEvent) => {
if (event.affectsConfiguration('workbench')) {
Copy link
Copy Markdown
Member

@IanMatthewHuff IanMatthewHuff Apr 10, 2019

Choose a reason for hiding this comment

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

Can we get more specific here? affectsConfiguration supports dotted names (I'm not totally sure what section the theme color is in). Could save us some unneeded checks. #Resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think "workbench.colorTheme" should work. Not 100% sure.


In reply to: 274070721 [](ancestors = 274070721)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure I'll try that.


In reply to: 274071214 [](ancestors = 274071214,274070721)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks. It worked.


In reply to: 274071761 [](ancestors = 274071761,274071214,274070721)

}
}

private computeKnownDark() : boolean {
Copy link
Copy Markdown
Member

@IanMatthewHuff IanMatthewHuff Apr 10, 2019

Choose a reason for hiding this comment

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

[](start = 30, length = 1)

In jupyterExecution you are removing all these spaces before the return type. #WontFix

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I probably did 'Format Document' in the other file. Tslint doesn't complain, so I don't think it really matters.


In reply to: 274076718 [](ancestors = 274076718)

Copy link
Copy Markdown
Member

@IanMatthewHuff IanMatthewHuff left a comment

Choose a reason for hiding this comment

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

:shipit:

@rchiodo rchiodo merged commit deb3fa7 into master Apr 10, 2019
@rchiodo rchiodo deleted the rchiodo/fix_unknowntheme branch April 10, 2019 19:30
@lock lock Bot locked as resolved and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants