Giter VIP home page Giter VIP logo

Comments (1)

bmalehorn avatar bmalehorn commented on July 21, 2024

Hey @xxxxxxbox, I'm definitely aware of this problem and run into it all the time. I do what you describe - I use the Move Line Downward keyboard shortcut (⌥ ↓ on Mac) to move it to the appropriate place after it's created.

print-it is a basic tool that just operates on text strings. It does not parse Python / JavaScript / Java / Ruby source code and does not understand a concept like "find the end of this statement". There are extensions, like the Python extension, that do parse Python code and tell VSCode how to syntax highlight each part, where function definitions are, etc.

However I'm not sure if there's any way in the VSCode extension API for print-it to get that language information from the Python extension. Correct me if I'm wrong, but I don't think there are any VSCode extensions that understand the Python language other than the Python extension itself.

So I probably will not implement this until VSCode extension API gives me a function like findStatementEnd({ line: 100, column: 5 }). If you find an API endpoint that does that sort of thing (or an extension that seems to understand Python code), feel free to let me know!

Also I could do some heuristic like trying to find a closing ) for the current line. I did that in another extension a while ago (https://github.com/bmalehorn/click-mode/blob/b94ea8cce89cf0e753b2ab915202d49ffc470fb6/click-mode.el#L66-L223), but most of that extension became parsing code which was always imperfect and could be tuned & special-cased forever. I'd rather insert the print statement in an obviously-wrong place rather than invite endless tweaks to the statement-finder code.

Does that all make sense?

from vscode-print-it.

Related Issues (8)

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.