Giter Site home page Giter Site logo

Comments (6)

numirias avatar numirias commented on September 22, 2024 1

Thanks for reporting! I can reproduce the issue and will look into it.

Thanks for this great plugin btw, I cannot live without it now. :D

Great to hear someone's using it in their daily workflow.

from semshi.

numirias avatar numirias commented on September 22, 2024 1

Unfortunately this appears to be another bug in Python's ast module, similar to #31. In this case, in a multi-line f-string, the syntax tree reports incorrect positions on lines beyond the first one.

Code example:

(
    f'aaa{foo}bbb'
    f'ccc{bar}ddd'
    f'eee{baz}fff'
)

Relevant part of the syntax tree:

JoinedStr(
    lineno=2,
    col_offset=4,
    values=[
        Str(lineno=2, col_offset=4, s='aaa'),
        FormattedValue(
            lineno=2,
            col_offset=4,
            value=Name(lineno=2, col_offset=10, id='foo', ctx=Load()),
            conversion=-1,
            format_spec=None,
        ),
        Str(lineno=2, col_offset=4, s='bbbccc'),
        FormattedValue(
            lineno=2,
            col_offset=4,
            value=Name(lineno=2, col_offset=5, id='bar', ctx=Load()),
            conversion=-1,
            format_spec=None,
        ),
        Str(lineno=2, col_offset=4, s='dddcccaaaaaaaaaaaaaa'),
        FormattedValue(
            lineno=2,
            col_offset=4,
            value=Name(lineno=2, col_offset=5, id='baz', ctx=Load()),
            conversion=-1,
            format_spec=None,
        ),
        Str(lineno=2, col_offset=4, s='ddd'),
    ],
),

The reported position for foo is correct (2,10), but not for bar (2,5) and baz (2,5).

I'm not sure there is an elegant workaround for this, but I'm open for suggestions. Also, I might introduce a switch to disable highlighting in f-strings.

I'll probably add this example to the Python bug report. Let's hope they will patch it at some point.

from semshi.

xiaket avatar xiaket commented on September 22, 2024

In my neovim, the color of "Sec is blue, just as name. And the length of the blue area is equal to the length of the variable name, that is, if I rename name to _name, the next char, u, will turn blue.

Hope you can reproduce this on your end.

Thanks for this great plugin btw, I cannot live without it now. :D

from semshi.

lervag avatar lervag commented on September 22, 2024

I also have the same issue. Seems to me to be the only thing I miss from python-syntax right now.

from semshi.

numirias avatar numirias commented on September 22, 2024

Duplicate of #31

from semshi.

ObserverOfTime avatar ObserverOfTime commented on September 22, 2024

The switch would be nice because I'm also having issues with f-strings.

from semshi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.