8000 Check for key in style before accessing. by rgant · Pull Request #757 · microsoft/TypeScript-Sublime-Plugin · GitHub
[go: up one dir, main page]

Skip to content

Check for key in style before accessing. #757

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

Merged
merged 1 commit into from
Dec 7, 2020
Merged

Check for key in style before accessing. #757

merged 1 commit into from
Dec 7, 2020

Conversation

rgant
Copy link
Contributor
@rgant rgant commented Sep 14, 2020

In the beta of Sublime Text v4 I get the following error in my console:

Exception in thread Thread-5:
Traceback (most recent call last):
  File "./python3.3/threading.py", line 901, in _bootstrap_inner
  File "./python3.3/threading.py", line 858, in run
  File "/Users/rgant/Library/Application Support/Sublime Text 3/Packages/TypeScript/typescript/libs/node_client.py", line 295, in __reader
    if NodeCommClient.read_msg(stream, msgq, asyncReq, proc, eventHandlers):
  File "/Users/rgant/Library/Application Support/Sublime Text 3/Packages/TypeScript/typescript/libs/node_client.py", line 194, in read_msg
    callback(data_dict)
  File "/Users/rgant/Library/Application Support/Sublime Text 3/Packages/TypeScript/typescript/commands/quick_info.py", line 148, in <lambda>
    cli.service.quick_info_full(self.view.file_name(), get_location_from_position(self.view, display_point), lambda response: self.handle_quick_info(response, display_point))
  File "/Users/rgant/Library/Application Support/Sublime Text 3/Packages/TypeScript/typescript/commands/quick_info.py", line 74, in handle_quick_info
    self.show_tooltip_popup(display_point, errors, error_html, info_text, info_str, doc_str)
  File "/Users/rgant/Library/Application Support/Sublime Text 3/Packages/TypeScript/typescript/commands/quick_info.py", line 80, in show_tooltip_popup
    theme_styles = get_theme_styles(self.view)
  File "/Users/rgant/Library/Application Support/Sublime Text 3/Packages/TypeScript/typescript/libs/popup_formatter.py", line 26, in get_theme_styles
    "type": format_css(view.style_for_scope("entity.name.type.class.ts")),
  File "/Users/rgant/Library/Application Support/Sublime Text 3/Packages/TypeScript/typescript/libs/popup_formatter.py", line 12, in format_css
    if (style["bold"]):
KeyError: 'bold'

I asked in the Sublime Discord about this and wbond responded:

From looking at the implementation, the various keys for boolean values are only set if true. So I could consider this a documentation bug.
https://discordapp.com/channels/280102180189634562/280157083356233728/755131743266406451

This change is just a check that the key exists (adds support for v4) and is true (support for v3).

@rgant
Copy link
Contributor Author
rgant commented Sep 14, 2020

Documentation for scope_for_style is here: https://www.sublimetext.com/docs/api_reference.html

Which is what they mean by "documentation bug".

@orta
Copy link
Contributor
orta commented Dec 7, 2020

Validated this locally - thanks @rgant

@orta orta merged commit 229f0d6 into microsoft:master Dec 7, 2020
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.

2 participants
0