Giter Site home page Giter Site logo

Comments (4)

EeyoreLee avatar EeyoreLee commented on July 25, 2024 2

@j-kleemann - Thanks! The addition commit is great! I'll merge it but release maybe tomorrow.

from vscode-extension-yapf.

EeyoreLee avatar EeyoreLee commented on July 25, 2024

@j-kleemann - yup, cause yapf will always add a empty line at then end and I just invoke it. The problem is yapf hasn't provide a release to format jupyter like black[jupyter], similar as jupyter magic function, so I do that on the extension side. Do you think it will be better if I always remove the empty line at the end in jupyter. Or do you have some situation that need the empty line at the end. There are already quite a few knobs here, so I want to try not to add extra new knob setting.

from vscode-extension-yapf.

EeyoreLee avatar EeyoreLee commented on July 25, 2024

@j-kleemann - hi, I create a PR that if your cell end with a empty line, it will hold on it and if your cell didn't has a empty line at the end, I will remove the empty line at the end. If it can fix your situation, I'll merge it later.

from vscode-extension-yapf.

j-kleemann-old avatar j-kleemann-old commented on July 25, 2024

@EeyoreLee - Wow that was quick! Thank you, I think your solution of keeping an existing blank line, while removing it if it hasn't been there before is ideal, way better and more flexible than any configuration switch!
While I am already happy with your solution, I still have one improvement idea:
Right now your code does not detect lines containing only whitespaces as blank, e.g, when formating

def f():
    pass # The next line seems empty, but it has four spaces.
    

it will remove the empty line at the end, which some people might not want (I actually realized that it can be quite useful to have the newline stay at the end, while one is still working on the cell 😅 and regularly you will have such whitespace-only lines because you hit enter on the previous line and vs code already intended the new line for you).
I added a rstrip(" \t") to your blank-line-detection code in PR #56, so it should now also consider lines containing only spaces and tabs as blank as well and keep a new line there (the tabs and spaces will be gone though, because yapf will remove them, but this should be fine and more often desired than not).

from vscode-extension-yapf.

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.