Skip to content

Spellchecker gets confused by f-strings #43

Description

@memeplex

The spellchecker is considering f'this in f'this is a f-string as a potential dictionary word and thereby highlighting it as wrong.

Activity

  1. kfollstad commented on Mar 18, 2021

    @kfollstad

    Hi @nfnty and all the other contributors,

    First off, I just wanted to say thanks for making such a great enhanced version of python syntax highlighting for vim. All the work that you guys have done to make this repo is so far ahead of upstream in terms of incorporating more coloring / new language features really shows.

    As far as this issue is concerned, the problem is essentially this:

    f"this"  # Will not be marked
    r"this"  # Will not be marked
    rf"this" # Will not be marked
    rf'this' # Will be marked as spelling error
    r'this'  # Will be marked as a spelling error
    f'this'  # Will be marked as a spelling error
    

    So I think what is happening is that spell check is being applied against the whole region including the start / end in all cases. However, in the case of the double quote (or triple double quotes) vim recognizes it as a word separation character and so checks "rf" and "this" as separate words. (R,f, rf, all pass). However in the case of a single quote, vim doesn't recognize it as a word separation character so it spellchecks the 'contraction' rf'this.

    I think the solution is wall off the start and end of the region with matchgroup

    Ref :help matchgroup
    In a start or end pattern that is highlighted with "matchgroup" the contained items of the region are not used. This can be used to avoid that a contained item matches in the start or end pattern match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions