Giter Site home page Giter Site logo

Comments (11)

Johann150 avatar Johann150 commented on September 22, 2024

#257 adressed the configurability of how many lines of context should be shown around labels.

from codespan.

Johann150 avatar Johann150 commented on September 22, 2024

For your other point, why don't you just put a (secondary) label on the context that you want to explain?

from codespan.

RDambrosio016 avatar RDambrosio016 commented on September 22, 2024

That is what i did, but i ended up scrapping it because:
The diagnostic references two nodes in a statement, i just want 3 - 5 lines around each label's location to tell the user "this is where the wrong stuff is" without having them have to go to the line. But this gets very cluttered in real world code. For example a try statement in js code (which is what i am doing) is usually decently large. And i reference something in the try {} block and the finally {} block, both of which may be large.

Overall, having another colored line adds clutter to the diagnostic, Your eyes should drift straight to the two places which are labelled, and you should instantly know where that code is. Having more things for the user to consider is ugly.

from codespan.

RDambrosio016 avatar RDambrosio016 commented on September 22, 2024

I think i will use the pre-release version for now with the context lines option for now. Then i will just update once it is released 👍

Edit: realized this is for multiline labels only for now, which isnt exactly what i need. hope an option for single labels could be added in the future.

from codespan.

Johann150 avatar Johann150 commented on September 22, 2024

Ah yes, its more of context inside labels. Mistake on my part 😓

from codespan.

ratmice avatar ratmice commented on September 22, 2024

@RDambrosio016 Any chance you could post an example (of the output generated) for such a case where either what you're trying to achieve or how it looks using secondary labels?

from codespan.

RDambrosio016 avatar RDambrosio016 commented on September 22, 2024

Sure, this is what it normally looks like without context. You cant really tell where exactly in the code it is unless you go back and look at the line numbers. This is how it is with a secondary label, i personally dont like it, and if the catch for example had a ton of stuff in it it would end up looking horrid. with context

Ideally i would just be able to say "3 lines of context around each label".

from codespan.

Johann150 avatar Johann150 commented on September 22, 2024

If you took the approach with a secondary label, you could adjust how many lines of context within the secondary label are shown (as I mentioned above). This would resolve the case of "if the catch had a ton of stuff in it". Your personal preference aside, I think this is a good alternative. Here is an example of how it would look using the current version:
image

from this source code
while(true){
    try{
        foo();
        foo();
        foo();
        foo();
        foo();
        foo();
        foo();
        foo();
        foo();
        foo();
        foo();
        if(condition()){
            continue;
        }
    }catch{
        bar();
        bar();
        bar();
        bar();
        bar();
        bar();
    }finally{
        break;
    }
}

This example shows me some other problems though:

  1. Something got lost on the way of resolving #259 with #260 and the locus is at the earliest label again (notice the error is supposedly on line 2 instead of line 25).
  2. What you mentioned already: The context should also work for secondary labels and single line labels. But I think it would be enough to enable this feature only if the label is inside another multiline label.
  3. Another thing that might make sense is to add something like tertiary labels which would look better than my "This is the finally block." label. They should not be rendered but just force the specific line to be shown.

from codespan.

RDambrosio016 avatar RDambrosio016 commented on September 22, 2024

Another thing that might make sense is to add something like tertiary labels which would look better than my "This is the finally block." label. They should not be rendered but just force the specific line to be shown.

I disagree with doing it like this, it should be something separate, maybe Context, a diagnostic would have a Vec<Context>. A context basically just holds a range and lines in those ranges will be rendered but without a label or coloring.

from codespan.

Johann150 avatar Johann150 commented on September 22, 2024

I found that there already is #29, which is I think more close to what you were trying to get at. In that light I think suggestion № 3 is not necessary.

№ 1 has already been solved in #282.

from codespan.

elkowar avatar elkowar commented on September 22, 2024

I'd really love a solution that allows me to both specify a range of lines to display without requiring a label around it (i.e. the proposed "context" field on a diagnostic), as well as allowing me to specify a default amount of lines of context for any label.
That latter option should imo just be part of the config struct, such that one can set
config.context_before = 2 and config.context_after = 2 so specify "show at least 2 lines before and two lines after my label as context.

I'd assume that implementing that latter half at least should be pretty trivial - I might try myself at a PR for that!

from codespan.

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.