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

Add Semantic Higlighter #7752

Merged
merged 1 commit into from
May 27, 2020
Merged

Add Semantic Higlighter #7752

merged 1 commit into from
May 27, 2020

Conversation

kapitanluffy
Copy link
Contributor

@kapitanluffy kapitanluffy commented Nov 10, 2019

Plugin for semantic highlighting to variables

Copy link
Collaborator

@packagecontrol-bot packagecontrol-bot left a comment

Choose a reason for hiding this comment

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

Automated testing result: WARNING

Repo link: Semantic Highlighter
Results help

Packages added:
  - Semantic Highlighter

Processing package "Semantic Highlighter"
  - WARNING: The binding ['ctrl+shift+l'] is also defined in default bindings but is masked with a 'context'
    - File: Default (Windows).sublime-keymap
  - WARNING: The binding ['ctrl+shift+e'] is also defined in default bindings but is masked with a 'context'
    - File: Default (Windows).sublime-keymap

Copy link
Collaborator

@packagecontrol-bot packagecontrol-bot left a comment

Choose a reason for hiding this comment

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

Automated testing result: SUCCESS

Repo link: Semantic Highlighter

Packages added:
  - Semantic Highlighter

Processing package "Semantic Highlighter"
  - All checks passed

@FichteFoll
Copy link
Collaborator

Why do you only define key bindings for Windows?

Setting change event handlers are registered for the entire settings objected and keyed by a string id for later removal, not for some setting name you provide.

As such, you must also unregister setting change handlers in a plugin_unloaded function as they will otherwise persist even when the package is unloaded.

What is the point of this context handler?

@FichteFoll
Copy link
Collaborator

@kapitanluffy ping

@FichteFoll FichteFoll added the stale The pull request needs to be updated but has not been within the recent past (2 weeks) label Feb 5, 2020
@kapitanluffy
Copy link
Contributor Author

Setting change event handlers are registered for the entire settings objected and keyed by a string id for later removal, not for some setting name you provide.

Hey sorry I got swamped with work. Can you elaborate on this one?

@FichteFoll
Copy link
Collaborator

It's like adding a key to a dictionary of callbacks that you can remove later by specifying the same key. Adding the same callback twice with different keys will result in the callback being called twice for every change.

@FichteFoll FichteFoll added timeout A pull request needed changes but was not updated in time (2 weeks after becoming stale) and removed stale The pull request needs to be updated but has not been within the recent past (2 weeks) labels Feb 26, 2020
@FichteFoll FichteFoll closed this Feb 26, 2020
@kapitanluffy
Copy link
Contributor Author

Hi @FichteFoll I updated the package. Can we reopen this PR?

@FichteFoll FichteFoll reopened this May 24, 2020
Copy link
Collaborator

@packagecontrol-bot packagecontrol-bot left a comment

Choose a reason for hiding this comment

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

Automated testing result: SUCCESS

Repo link: Semantic Highlighter

Packages added:
  - Semantic Highlighter

Processing package "Semantic Highlighter"
  - All checks passed

@FichteFoll
Copy link
Collaborator

Setting change event handlers are registered for the entire settings objected and keyed by a string id for later removal, not for some setting name you provide.

This is still handled incorrectly, although it doesn't break with how it is currently. I suggest to just read the corresponding settings from the settings object directly when you want to use them instead of using a settings listener.

What is the point of this context handler?

@FichteFoll FichteFoll removed the timeout A pull request needed changes but was not updated in time (2 weeks after becoming stale) label May 24, 2020
@kapitanluffy
Copy link
Contributor Author

kapitanluffy commented May 24, 2020

Setting change event handlers are registered for the entire settings objected and keyed by a string id for later removal, not for some setting name you provide.

This is still handled incorrectly, although it doesn't break with how it is currently. I suggest to just read the corresponding settings from the settings object directly when you want to use them instead of using a settings listener.

What is the point of this context handler?

I rewrote the whole thing. The context handler is for the keybindings. Let me know if there's a better way of doing that :)

Also, for the settings listener issue, do you mean that on add_on_change it fires the callback everytime any setting is changed on that Setting object?

So with that in mind, I should do:

preferences = sublime.load_settings('Preferences.sublime-settings')
preferences.add_on_change('my_plugin_key', my_callback_for_changes)

@kapitanluffy
Copy link
Contributor Author

Tried reading the settings directly instead of registering a callback but I realized that it would read the settings file with every cursor move (which I think is very inefficient).

I think I understood what you are saying now regarding the listeners though.

@FichteFoll
Copy link
Collaborator

FichteFoll commented May 25, 2020

Also, for the settings listener issue, do you mean that on add_on_change it fires the callback everytime any setting is changed on that Setting object?

Yes.

I rewrote the whole thing. The context handler is for the keybindings. Let me know if there's a better way of doing that :)

The current implementation is still the same and a no-op. It will always match when the corresponing "key" is provided, in which case you might as well omit it entirely.

Tried reading the settings directly instead of registering a callback but I realized that it would read the settings file with every cursor move (which I think is very inefficient).

Hm, that may indeed be a valid reason to have a cache in form of a native Python dict. You could time/benchmark it to be sure, but I understand the reasoning.

@kapitanluffy
Copy link
Contributor Author

Also, for the settings listener issue, do you mean that on add_on_change it fires the callback everytime any setting is changed on that Setting object?

Yes.

I rewrote the whole thing. The context handler is for the keybindings. Let me know if there's a better way of doing that :)

The current implementation is still the same and a no-op. It will always match when the corresponing "key" is provided, in which case you might as well omit it entirely.

Tried reading the settings directly instead of registering a callback but I realized that it would read the settings file with every cursor move (which I think is very inefficient).

Hm, that may indeed be a valid reason to have a cache in form of a native Python dict. You could time/benchmark it to be sure, but I understand the reasoning.

I removed the keybinding contexts for now. I fully understand what contexts are for now after reading about it on the docs.

I also removed a mousemap file that I forgot included in the repo.

@FichteFoll FichteFoll merged commit 64c7882 into wbond:master May 27, 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.

3 participants