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

cmd/govim: Ensure text prop highlights aren't placed when disabled #730

Merged
merged 1 commit into from
Jan 27, 2020

Conversation

leitzler
Copy link
Member

The config HighlightDiagnostics can be used to disable in-code
highlights. PR #700 accidently broke that feature so that it was
possible to get highlights even when disabled.

This PR ensures that text prop highlights aren't placed when they
are disabled by the config.

Fixes #724

The config HighlightDiagnostics can be used to disable in-code
highlights. PR #700 accidently broke that feature so that it was
possible to get highlights even when disabled.

This PR ensures that text prop highlights aren't placed when they
are disabled by the config.

Fixes #724
@leitzler leitzler requested a review from myitcv January 27, 2020 20:40
Copy link
Member

@myitcv myitcv left a comment

Choose a reason for hiding this comment

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

LGTM with a couple of comments/questions. Also, I think we should have a test for the bug to go into https://github.com/govim/govim/tree/master/cmd/govim/testdata/scenario_bugs

@@ -51,7 +51,7 @@ func (v *vimstate) textpropDefine() error {
}

func (v *vimstate) redefineHighlights(diags []types.Diagnostic, force bool) error {
if !force && (v.config.HighlightDiagnostics == nil || !*v.config.HighlightDiagnostics) {
if v.config.HighlightDiagnostics == nil || !*v.config.HighlightDiagnostics {
Copy link
Member

Choose a reason for hiding this comment

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

It bothers me that force now means something different for quickfix, signs and highlights. Worth fixing now, or would you like to leave that for a later PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

As per our slack conversation, I'll leave it as is for now.

When this is merged we'll have the following meaning of force:

  • Highlights: Update even if there are no new diagnostics
  • Signs: Update even if there are no new diagnostics
  • Quickfix: Update even if there are no new diagnostics AND ignore if auto quickfix is disabled via config

@@ -113,7 +113,18 @@ func (v *vimstate) setConfig(args ...json.RawMessage) (interface{}, error) {
if !vimconfig.EqualBool(v.config.HighlightDiagnostics, preConfig.HighlightDiagnostics) {
if v.config.HighlightDiagnostics == nil || !*v.config.HighlightDiagnostics {
// HighlightDiagnostics is now not on - remove existing text properties
v.redefineHighlights([]types.Diagnostic{}, true)
v.BatchStart()
for bufnr, buf := range v.buffers {
Copy link
Member

Choose a reason for hiding this comment

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

It also bothers me that we leak this sort of detail into the handling of config changes. Worth fixing now, or would you like to leave that for a later PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point. I did consider breaking out the feature to a removeHighlights but went with this since it is how it's done for both signs and quickfix entries above.

@leitzler leitzler merged commit 60a1430 into master Jan 27, 2020
@leitzler leitzler deleted the cmd_govim_fix_disabling_diags branch January 27, 2020 21:13
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.

cmd/govim: Disabling HighlightDiagnostics sometimes doesn't work
2 participants