Giter VIP home page Giter VIP logo

Comments (9)

kbrose avatar kbrose commented on June 16, 2024

Interesting idea! I'd be happy to review a PR that adds this functionality.

from vsc-python-indent.

asdasd-123 avatar asdasd-123 commented on June 16, 2024

I have no idea how to add it sorry. My point was that the IDE does this by default but this plugin breaks it lol

from vsc-python-indent.

kbrose avatar kbrose commented on June 16, 2024

I'd written less than one hundred lines of javascript/typescript before writing this extension. Don't sell yourself short!

from vsc-python-indent.

WhistleWhileYouWork avatar WhistleWhileYouWork commented on June 16, 2024

Just wanted to put my 2 cents in. I do this a lot! I constantly have to go back and resize my comments after I end up indenting a block and shortening the horizontal space. I'll have another look at the code but it seems the section that looks for the # just exits after it is detected. Is this where new code needs to go?

  1. Detect if there is text after the cursor
  2. Make new line indent same as current line
  3. Add # after the indent and before the cursor with remaining text after cursor

With this issue fixed, this extension should be complete!

from vsc-python-indent.

kbrose avatar kbrose commented on June 16, 2024

I would probably make this a separate function instead of trying to add another output to the already very complex parser.

Something else to think about is the behavior if there is non-comment text. How should the below work?

def f(x):  # this is| gonna be great!

(The pipe represents your cursor.)

Iā€™d make a simple function that checks the line is only white space and comment, and that your cursor is inside the comment, and in that case sets the insertion text to include #

from vsc-python-indent.

WhistleWhileYouWork avatar WhistleWhileYouWork commented on June 16, 2024

That was the only edge case I could come up with as well, and I believe the appropriate action is to follow VSCode's behavior which is to not comment the following line. This makes sense as there should be no expectation by the programmer to have the comment continue on the next line since single line code/comments are meant to be just that - a single line. I have never seen a same-line code comment continue to the line below.

This will take some time for me to get to, but I would like to see this fixed since this one is frustrating (and as far as I'm concerned the final bug).

from vsc-python-indent.

kbrose avatar kbrose commented on June 16, 2024

Should be working in v1.5.0. Please reopen/open a new issue if the problem persists.

I matched the behavior of vanilla VSCode, even though I think it's sub-optimal in the case when you have a space to the right of your cursor (you end up with two spaces):

def f():
    # This function is| gonna be REAL good!

def f():
    # This function is
    # | gonna be REAL good

PRs for better behavior welcome!

from vsc-python-indent.

WhistleWhileYouWork avatar WhistleWhileYouWork commented on June 16, 2024

Nice!

I don't think it's sub-optimal at all. The result is exactly what I would expect. Because I know I'm entering a new line, I always highlight the space before hitting ENTER. I don't think the extension should try to be too 'smart'. Just look at the issues with the latest version of the python extension: microsoft/vscode-python#6886

from vsc-python-indent.

kbrose avatar kbrose commented on June 16, 2024

Yeah, that behavior was driving me nuts today. I thought I went crazy and spent a good amount of time trying to figure out how to turn it off. I discovered it while pasting and was really confused why I was getting format on paste when I specifically turned off the format-on-paste setting.

I do think a little intelligence wouldn't be terrible here. If there is (possibly exactly) one space to the right of the cursor, do not add a space, just a #.But I obviously didn't feel strong enough to do it myself, so /shrug

from vsc-python-indent.

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.