Comments (9)
Interesting idea! I'd be happy to review a PR that adds this functionality.
from vsc-python-indent.
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.
I'd written less than one hundred lines of javascript/typescript before writing this extension. Don't sell yourself short!
from vsc-python-indent.
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?
- Detect if there is text after the cursor
- Make new line indent same as current line
- 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.
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.
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.
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.
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.
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)
- install extension offline, not compatible version HOT 1
- Extension causes high cpu load HOT 2
- Maybe adjust behavior of useTabOnHangingIndent? HOT 1
- keepHangingBracketOnLine doesn't seem to be working for square brackets HOT 3
- Automatic dedent for return doesn't always work HOT 13
- One space get inserted HOT 1
- # region Description invalid
- Connection to server got closed. Server will not be restarted. HOT 2
- Fail to generate Indentation for a specific file and code copied from that file HOT 1
- Causes big lags in the editor HOT 2
- Connection to server got closed. Server will not be restarted HOT 1
- Enter doesn't work HOT 4
- Enter button not working fine
- Input lag on Keyboard key
- There is no formatter for 'python' files installed
- Extreme lag from pressing Enter to action when extension is running in remote (ssh) host. HOT 6
- multiple indent blank lines will not clear white space before line HOT 2
- Highlighting ` *` and pressing enter doesn't do anything. HOT 1
- python Indentation of the current line is automatically reduced after line wrap HOT 2
- Add extra 3 whitespaces when add new line and broke indent HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vsc-python-indent.