Fix problems that can occur when we can't find the theme json#5177
Conversation
Add support for when theme files aren't found.
|
|
||
| @injectable() | ||
| export class DataViewer implements IDataViewer, IAsyncDisposable { | ||
| export class DataViewer extends WebViewHost<IDataViewerMapping> implements IDataViewer, IDisposable { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
PostOffice [](start = 8, length = 10)
Because the postoffice isn't a component anymore, we need to cleanup after every test. #Resolved
| @@ -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 | |||
There was a problem hiding this comment.
This seems like a good candidate for a manual test case in our CTI test plan file. #Resolved
There was a problem hiding this comment.
I agree. Is that in our source somewhere? I can update it here.
In reply to: 274056601 [](ancestors = 274056601)
There was a problem hiding this comment.
| 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'; |
There was a problem hiding this comment.
Not directly part of this checkin, but the default for cursorStyle for VSCode is line, not block. #ByDesign
There was a problem hiding this comment.
There was a problem hiding this comment.
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 ; |
There was a problem hiding this comment.
we are already inside a if(theme) block here #Resolved
There was a problem hiding this comment.
| } | ||
|
|
||
| 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 } => { |
There was a problem hiding this comment.
More of a style issue, but for X | undefined I'd usually just use ? notation, especially as a parameter. #ByDesign
There was a problem hiding this comment.
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)
|
|
||
| // Post a message to our webpanel and update our new datascience settings | ||
| private onPossibleThemeChange = (event: ConfigurationChangeEvent) => { | ||
| if (event.affectsConfiguration('workbench')) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
I think "workbench.colorTheme" should work. Not 100% sure.
In reply to: 274070721 [](ancestors = 274070721)
There was a problem hiding this comment.
There was a problem hiding this comment.
| } | ||
| } | ||
|
|
||
| private computeKnownDark() : boolean { |
There was a problem hiding this comment.
[](start = 30, length = 1)
In jupyterExecution you are removing all these spaces before the return type. #WontFix
There was a problem hiding this comment.
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)
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.
package-lock.jsonhas been regenerated by runningnpm install(if dependencies have changed)