Giter VIP home page Giter VIP logo

vsc-python-indent's People

Contributors

cbrnr avatar chen19901225 avatar dependabot[bot] avatar dspeckhals avatar kbrose avatar whistlewhileyouwork avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vsc-python-indent's Issues

VsCode issue : Fails to get new line after installing this extension

Describe the bug
When I installed this extension on my VsCode Application, it failed as I was not able to add a new blank line (pressing the Enter key).

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots:
If you want, attach screenshots/videos/gifs to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. ubuntu 18.04, Mac OS Mojave]
  • Version of Python Indent [e.g. 0.7.0]
  • Version of Visual Studio Code [e.g. 1.33.1]

Additional context:
Add any other context about the problem here.

The plug-in is not compatible with vscode-neovim

Hi, I've been trying out vscode-neovim lately and seems it is not fully compatible with python-indent

The exact issue:

when pressing o in normal mode, it shall insert a line below the current cursor line. However with python-indent enabled, it enters insert mode and leave the cursor in the same line.

I'm not entirely sure it is a python-indent issue or from vscode-neovim. But i have to give up python-indent for now as I'm migrating most workflow on vscode nowadays.

Let me know if additional info is needed on the bug.

Add extra 3 whitespaces when add new line and broke indent

#code before enter

def json_handler(self_data):
    
	if ( self_data['WIFI']['MODE']['current'].upper() == 'CLIENT' ):
        
		rc, result = CmdTool("wifi-clientup", "tpntoolkit wificlientup").run()
		if rc == 0 :
			result_message = get_wifi_status()
		else:
			result_message = "{}"
	else:
     
		rc, result = CmdTool("wifi-hostapup", "tpntoolkit wifiap").run()
		if rc == 0 :
			result_message = get_wifi_status()
		else:
			result_message = "{}"|

#code after enter with broke ident warning

def json_handler(self_data):
    
	if ( self_data['WIFI']['MODE']['current'].upper() == 'CLIENT' ):
        
		rc, result = CmdTool("wifi-clientup", "tpntoolkit wificlientup").run()
		if rc == 0 :
			result_message = get_wifi_status()
		else:
			result_message = "{}"
	else:
     
		rc, result = CmdTool("wifi-hostapup", "tpntoolkit wifiap").run()
		if rc == 0 :
			result_message = get_wifi_status()
		else:
			result_message = "{}"
...return result_message

Wrong indentation for try..except..else / for..else / while..else

Minimal code example:

What the code looks like before pressing enter:

if True:
    try:
        pass
    except:
        pass
    else:|

What I want the code to look like after pressing enter:

if True:
    try:
        pass
    except:
        pass
    else:
        |

What the code actually looks like after pressing enter:

if True:
    try:
        pass
    except:
        pass
else:
    |

Same problem if instead of try ... except ... else, I do for ... else or while ... else.

Arguably the current behavior may be what many users expect and thus be left as is. For me, personally, an option to disable automatic else: dedentation would also work. In any case, this is not crucial at all, I'm fine correcting the automation once in a while. Thanks again for all the key presses saved so far!

multiple indent blank lines will not clear white space before line

When I enable python-indent,I input multiple blank line which need indent,before all line will keep white space include before line,just like this pic:
image

(It will show all white space in my vscode)

but if I disable this plugin, It's will automatic delete white space, like this

image

I don't know this is a feature or a bug, if you need more information can ask me, hope your reply

Blank lines retain the inserted indentation on Enter

Using the editor without Python Indent installed, the auto-inserted indentation is removed when enter is pressed on a line which is otherwise blank. With Python Indent installed, we end up with trailing whitespace.

What the code looks like before pressing enter:

def my_example():
    print('something')
····|

What I want the code to look like after pressing enter:

def my_example():
    print('something')

····|

What the code actually looks like after pressing enter:

def my_example():
    print('something')
····
····|

(· here denotes an actual space)

Enter when in a if-line

Let's us enter in a code line like Pycharm IDE
It's should be looks like the right side of the image

Capture

Hanging indent options on continuation lines

First of all, I love this extension. It has made using VS Code such a breeze, so thank you immensely for making it available.

This may be closer to a feature request, but it would be great to have indentation options for continuation lines. There are no hard and fast rules here, but some linters call for four spaces for indents on continuation lines (e.g. Flake8 E121). That is, some linters call for using two tabs on new lines as opposed to one. To be concrete,

Minimal code example:

What the code looks like before pressing enter:

long_variable_name = long_function_name(|)

What I want the code to look like after pressing enter:

long_variable_name = long_function_name(
    |
)

What the code actually looks like after pressing enter:

long_variable_name = long_function_name(
  |
)

Obviously this is subject to personal taste, but it would be great to have indentation options so e.g. the Flake8 preference could be applied by default, if desired by the user. Thanks a lot!

Extension is not activated with highlighted text and pressing ENTER

First off, thank you for putting in the time to create and share this nifty little tool!

I noticed the following minor inconsistency and I thought I would share it just in case it was important (personally I can live with it) or if the fix is simple (I'm guessing this may only require also registering the ENTER key for the extension when text is highlighted). At the very least, I suggest putting this in the Caveats section.

Minimal code example:

What the code looks like before pressing enter:

my_dict = {'a': 1, |'b': 2}
# Now highlight the space between the dict entries to bring 'b' to a new line and eliminate the would-be trailing space

What I want the code to look like after pressing enter:

my_dict = {'a': 1,
           'b': 2}|
# No trailing space and code is aligned

What the code actually looks like after pressing enter:

my_dict = {'a': 1,
'b': 2}|
# No trailing space but code is not aligned

Often times, we have to go back and change our code and sometimes we run up against linting line limits when we add to a line of code. We then have to choose a place to break the line into two lines. Invariably this logical break occurs at a separation point that involves a space. In order to avoid getting lint-bombed, we delete the space. I prefer to highlight the space and hit ENTER. I'm sure that there are a lot of keyboard-only people that will never encounter this and the alternative of course is to simply delete the space before or after hitting ENTER.

Environment (please complete the following information):

  • Python Indent version: [e.g. 1.0.0]
  • Visual Studio Code version: [e.g. 1.35.1]
  • OS: Windows 10 1809 64 bit

Close parens on indented line

Just a matter of taste but I prefer to close parens at the end of the indented line instead of putting them on a new line, i.e.

variable = function(
    |)

instead of


variable = function(
    |
)

It seems like it should be fairly easy to add a config setting to specify this (I could have a crack at it myself although I am not familiar with TS). Would this be desirable?

Implement the new `python-indent-parser` library

Is your feature request related to a problem? Please describe.
I think it would be helpful to implement the python-indent-parser (most of it being code you wrote) library you originally suggested in Atom's python-indent repo.

Describe the solution you'd like
Feel free to implement it youself; otherwise, I don't mind taking care of it. It should be pretty painless: the API is virtually the same, as well as the code. The only thing I added was a "canHang" flag that helps to properly determine if the previous line has context to indicate a hanging indent. The code currently here didn't work with Atom when Python comments were involved.

Describe alternatives you've considered
A mono repo that includes python-indent, python-indent-parser, and python-indent-vsc could also be used, but that's mainly just an optimization.

Additional context
I'd be very willing to give you co-ownership/collaborator status in the python-indent-parser library if you want. That way you wouldn't have to depend on me for any necessary changes to the core functionality.

Thanks for all of the thinking and coding you've put into the parser; it definitely fills a gap that both Atom and VS Code have when it comes to proper Python indentation!

install extension offline, not compatible version

I'm working with some webIDE with online version of vscode, and I cannot change the version of vscode. I can only install the extensions with downloaded package, but the current version is not compatible with the vs code I'm using, it's 1.56.0. Where could I download the previous/compatible version of your package?

Cannot create a newline in python scripts

I am not sure if this is a problem in my setup, however, this is a fresh install of the extension.

Whenever I create a new python file, I am unable to create newlines. Supposing I create a file named test.py and try to add a statement.

import os  # try to create a newline after this statement

I keep getting this error.

image

Here are my settings:

image

Highlighting ` *` and pressing enter doesn't do anything.

Let's say you have some lines in your editor that looks like this:

literally anything here<PLACE CURSOR HERE> *
some more things
here
and<END HIGHLIGHT HERE>
here

Put your cursor in the place I identified, and hold shift and press down like you're highlighting the section. It's very important to place your cursor at the EXACT place I mentioned because it doesn't work anywhere else. It is also important that there is at least a single space between the starting cursor position and the * in order to reproduce the bug properly.

If you press down while holding shift to highlight the section, then press enter, I would expect the editor to delete everything that was highlighted and start a new line such that it would end up looking like this:

literally anything here

here

Instead, when you press enter, the editor won't delete anything and return your cursor to the same position it started in. So it looks like this

literally anything here<CURSOR ENDS UP HERE> *
some more things
here
and
here

After removing this extension, I'm no longer having this issue.

Bug in indentation of else: and elif in python

This is an remaining issue after the fix in #19

Here is how it works:

while True:
    result = i / 3
    if something:
        output = "Hello"
        elif something:

When I press enter at the last line above, the elif will be moved correctly to be on the same level as the if. No issues here.
This is how it looks after enter

while True:
    result = i / 3
    if something:
        output = "Hello"
    elif something:

But now lets say that I wanted to edit the elif somewhat, so I do this:

while True:
    result = i / 3
    if something:
        output = "Hello"
    elif some

And I then edit it to:

while True:
    result = i / 3
    if something:
        output = "Hello"
    elif somethingelse:

I press enter at the last line above, and get this:

while True:
    result = i / 3
    if something:
        output = "Hello"
elif somethingelse:

I think that the solution is to only indent it once, and not on subsequent edits of the line.
The above is an example with elif, but the same goes for else:

Environment (please complete the following information):

  • OS: OSX Mojave
  • Version of Python Indent 1.1.0
  • Version of Visual Studio Code: 1.35.0

No hanging indent after line continuation '\' without an enclosing (),[] or {}

The default behavior for VSCode is to have a hanging indent. This issue does not occur if the \ is inside (), [] or {}.

What the code looks like before pressing enter:

def my_example():
    test = this + \|

What I want the code to look like after pressing enter:

def my_example():
    test = this + \
        |    # Hanging indent

What the code actually looks like after pressing enter:

def my_example():
    test = this + \
    |

Environment (please complete the following information):

  • Python Indent version: [e.g. 1.2.0]
  • Visual Studio Code version: [e.g. 1.36.1]
  • OS: Windows 10 1809

Space after line break

Minimal code example:

What the code looks like before pressing enter:

result = my_func(first_argument, second_keyword=some_value1,| third_keyword=some_value2)

What I want the code to look like after pressing enter:
(no space between cursor and third_keyword)

result = my_func(first_argument, second_keyword=some_value1,
                |third_keyword=some_value2)

What the code actually looks like after pressing enter:
(but space left between cursor and third_keyword)

result = my_func(first_argument, second_keyword=some_value1,
                | third_keyword=some_value2)

Extreme lag from pressing Enter to action when extension is running in remote (ssh) host.

Due to network speed or load on the remote host machine sometimes I experience huge delays from when I press the Enter key until I see the cursor move. It can get up to 10 sec sometimes and there is noting more annoying than typing unresponsiveness.

I guess my question is that does the extension have to run on the remote site or it can achieve the same result running locally?
If it can't be run locally, then is it possible to have a timeout of max one second (or maybe adjustable via settings) for remote host to respond and if it doesn't respond it just run normal Enter?

Additional closing parentheses added

Thanks for your work.

When you open a parentheses, closing parentheses is added automatically.
And then although you type closing parentheses, it won't added and just the cursor will be moved to the right.
But sometimes, closing parentheses is added.

Normal case.

# Step 1.

d = {'a': |}

# Step 2.

d = {'a': [|]}

# Step 3.

d = {'a': [1,2|]}

And then write closing parentheses, but only cursor will be moved.
# Step 4.

d = {'a': [1,2]|}

Bug case.

# Step 1.

d = {'a': |}

# Step 2.

d = {'a': [|]}

# Step 3.

d = {'a': [1,2|]}

Enter the return before closing parentheses, and add some more values.
# Step 4.

d = {'a': [1,2,
           3,4|]}

And then type closing parentheses. Closing parentheses added.
# Step 5.

d = {'a': [1,2,
           3,4]|]}

This bug happened for "]" and "}". I think other parentheses may be same.

Detection of variable names as control statements e.g. 'return_x' treated as 'return'

What the code looks like before pressing enter:

def my_example():
    return_x = 1|

What I want the code to look like after pressing enter:

def my_example():
    return_x = 1
    |

What the code actually looks like after pressing enter:

def my_example():
    return_x = 1
|

The section in parseLines looks for dedentNextKeywords by using startswith() but that would allow any variable name starting with "return", "pass", "break", "continue" or "raise" to be counted as a keyword and the resulting dedent would be incorrect. I will submit a pull request shortly.

Environment (please complete the following information):

  • Python Indent version: [e.g. 1.1.0]
  • Visual Studio Code version: [e.g. 1.36.1]
  • OS: Windows 10 1809

Incorrect line breaking in multi cursor mode

Describe the bug
Hello! Lines don't break properly when I press "enter" in multicursor mode.

Extension enabled:

Extension disabled:

Environment (please complete the following information):

  • OS: Manjaro
  • Version of `Python Indent 0.7.0
  • Version of Visual Studio Code 1.34.0

Python: Return key does not work after some time

Issue Type: Bug

In some cases the editor does not react on the return key when editing a Python file (other keys are still working, but you can't add a new line which is quite annoying).

I can' really tell the circumstances in which this phenomenon occurs.

After disabling the extension, the problem disappeared.

Extension version: 1.11.0
VS Code version: Code 1.50.1 (d2e414d9e4239a252d1ab117bd7067f125afd80a, 2020-10-13T15:06:15.712Z)
OS version: Windows_NT x64 10.0.18363

Not auto-scroll when press Enter

When I move the cursor to the end of last line at viewable area, and press Enter, cursor will disappear . When I disabled this extension and do same thing above, screen will auto-scroll. The default action when press Enter is to let cursor at viewable area. I think the default auto-scroll is worth keeping.

else: incorrectly dedented

As far as I can tell, the issue in #31 is still present in 1.4.0

Tested with the below. Put the cursor to the right of the "else:" and press enter. The else: indents on the the left even when there is no if statement on that level.

def my_function(x):
    if x > 0:
        if x == 5:
            print(x)
    else:

Extension doesn't work in unsaved buffer

I've tried your extension and I really like it! One thing I've noticed is that it doesn't work in an unsaved buffer (even after setting the language mode to Python) - would it be difficult to fix this?

wrong indent when use "elif"

def foo():
    if 1:
        pass
    elif 0:#click "enter"

after click "enter",it comes to

def foo():
    if 1:
        pass
elif 0:
    |#new line

Incorrect indentation of "elif", "else", "except", "finally" keywords depending on their indent level before pressing ENTER

The extension tries to handle if and try blocks by de-denting the current line based on whether the previous line was a control statement or not (pass, return, continue etc...). It assumes that the starting location of the new line is where the extension would have put it (this isn't always the case) and then de-dents in certain scenarios. Having the start of the line in a different location is where we get the issue. Examples that illustrate the extension's intended logic (the two examples produce the intended output correctly):

  1. With pass statement before enter:
def test():
    if x:
        pass|

After enter:

def test():
    if x:
        pass
    |
  1. With non-control statement before enter:
def test():
    if x:
        some_code = ''|

After enter:

def test():
    if x:
        some_code = ''
        |

After typing else::

def test():
    if x:
        some_code = ''
        else:|

After enter:

def test():
    if x:
        some_code = ''
    else:
        |

However, a user might come back to an if statement and add an else statement such as this example (before pressing enter):

def test():
    if x:
        some_code = ''
    else:|

We expect to see this after pressing enter:

def test():
    if x:
        some_code = ''
    else:
        |

What the code actually looks like after pressing enter:

def test():
    if x:
        some_code = ''
else:
|

The extra de-dent logic won't work properly unless the extension looks back to previous lines to find the location of the corresponding if or try statement to ensure it only de-dents dedentKeywords that need it. Removing lines 27-34 from indent.ts solves the issue but requires the user to manually de-dent before typing else: in the case of the second example. That isn't so bad considering we have to do this anyway without the extension.

Environment (please complete the following information):

  • Python Indent version: [e.g. 1.0.0]
  • Visual Studio Code version: [e.g. 1.36.0]
  • OS: Windows 10 1809

Use with other commands in macros(vs code extension)

I used to use Shift+Enter to insert a newline after current line, but the newline still has same indent with previous line, even the previous line is a Return Statement. So I want to use this indent etension to solve it. My idea is use macros and config the order like that:

"macros": {
        "insertLineAfterWithAutoIndent": [
             "cursorEnd",
             "pythonIndent.newlineAndIndent",
         ]
}

and bind this command with keyboard shortcuts Shift+Enter, but the result is not satisfied. It executes "pythonIndent.newlineAndIndent" firstly, and then executes "cursorEnd", I don't know why order is changed and want know whether this idea can be realize.

Possibility to transfer functionality to other languages?

Love this extension so much the only thing going against it is that it makes me want one for R even more!

Was wondering what your views are on extending the current extension to work with other languages or whether such an extension would logically need to be build up from scratch.

Keep up the great work!

Broken indentation of continuation lines

If I have the following code

    sql = ('SELECT mode FROM pg_locks JOIN pg_class '
           'ON pg_class.oid = pg_locks.relation '
           'JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace '
           f'WHERE pg_class.relname = {table_name!r} '
           f'AND pg_namespace.nspname = {schema!r};')

And press tab I would expect the whole block to be indented four spaces, maintaining the lines alined. Instead I get

        sql = ('SELECT mode FROM pg_locks JOIN pg_class '
            'ON pg_class.oid = pg_locks.relation '
            'JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace '
            f'WHERE pg_class.relname = {table_name!r} '
            f'AND pg_namespace.nspname = {schema!r};')

Not sure if this is a larger VSCode problem (it does the same without Python Indent). Is there any way to get this to work?

Allow indent using tabs instead of spaces

Is your feature request related to a problem? Please describe.
Hi. Is it possible to extend the functionality of this extension to 'Indent using Tab' also? I personally prefer Tab over Spaces because I find it easy to navigate in code when I use 'tab'.

Describe the solution you'd like
The extension works for 'Indent using Tab' too.

Describe alternatives you've considered
I am using 'Indent using Spaces' instead of 'using Tabs'

Additional context

*...else...else dedentation

Minimal code example:

What the code looks like before pressing enter:

if True:
    for i in range(5):
        print(i)
    else:
        print('no break!')
        else:|

What I want the code to look like after pressing enter:

if True:
    for i in range(5):
        print(i)
    else:
        print('no break!')
else:|

What the code actually looks like after pressing enter:

if True:
    for i in range(5):
        print(i)
    else:
        print('no break!')
    else:|

Also, starting from

if True:
    for i in range(5):
        print(i)
    else:
        print('no break!')
    else:|

should end up with the desired behavior shown above too.

Typically, I don't dedent past the point where the else/elif/except/finally keyword could be placed and still be syntactically correct, but in cases like these where we've already "consumed" the for's (or while's or try's) else, we know that the final else must be meant for the if.

this plugin breaks `:w` in vim plugin

I've narrowed it down to this plugin.

When using this plugin with the vim plugin, it breaks the very important :w operator to save your file. When disabling vsc-python-indent, :w works well. When enabling it, :w fails when editing any .py file. This is the stack trace in dev tools:

mainThreadExtensionService.ts:60 [[object Object]]Illegal value for `line`
$onExtensionRuntimeError @ mainThreadExtensionService.ts:60
_doInvokeHandler @ rpcProtocol.ts:399
_invokeHandler @ rpcProtocol.ts:384
_receiveRequest @ rpcProtocol.ts:304
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:584
a @ ipc.net.ts:392
e @ ipc.net.ts:399
fire @ event.ts:584
_receiveMessage @ ipc.net.ts:678
_socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:549
fire @ event.ts:584
acceptChunk @ ipc.net.ts:212
_register._socket.onData.e @ ipc.net.ts:173
t @ ipc.net.ts:24
emit @ events.js:182
addChunk @ _stream_readable.js:279
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onread @ net.js:636
mainThreadExtensionService.ts:61 Error: Illegal value for `line`
	at u._lineAt (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:356)
	at Object.lineAt (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:355)
	at TagManager.getWordAtPosition (/home/ryan/.vscode/extensions/formulahendry.auto-rename-tag-0.0.15/out/src/tagManager.js:36)
	at TagManager.getCurrentWord (/home/ryan/.vscode/extensions/formulahendry.auto-rename-tag-0.0.15/out/src/tagManager.js:29)
	at run.vscode.window.onDidChangeTextEditorSelection.event (/home/ryan/.vscode/extensions/formulahendry.auto-rename-tag-0.0.15/out/src/tagManager.js:11)
	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:44)
	at c.$acceptEditorPropertiesChanged (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:577)
	at d._doInvokeHandler (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:622)
	at d._invokeHandler (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:621)
	at d._receiveRequest (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:620)
	at d._receiveOneMessage (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:619)
	at define.constructor._protocol.onMessage.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:617)
	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:44)
	at e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:40)
	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:44)
	at a (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:172)
	at e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:172)
	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:44)
	at y._receiveMessage (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:181)
	at define.constructor._socketDisposables.push._socketReader.onMessage.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:178)
	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:44)
	at f.acceptChunk (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:175)
	at define.constructor._register._socket.onData.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:174)
	at Socket.t (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:182)
	at Socket.emit (events.js:182)
	at addChunk (_stream_readable.js:279)
	at readableAddChunk (_stream_readable.js:264)
	at Socket.Readable.push (_stream_readable.js:219)
	at Pipe.onread (net.js:636)```

Continuing strs when broken across lines

Love the extension. Thanks for the work.

It would be great if str literals could be continued when broken across lines.

I had a line of code Like this:

my_str = f"{steps: >5d}    3    1    3    0{nodes: >5d}{elements: >5d}{boundaries: >5d}{materials: >5d}{optional(interfaces, ' >5d'):s}    1"

...and (with the help of Python Indent) reformatted it like this:

my_str = (f"{steps: >5d}    3    1    3    0"
          f"{nodes: >5d}{elements: >5d}"
          f"{boundaries: >5d}{materials: >5d}"
          f"{optional(interfaces, ' >5d'):s}    1")

A cool feature would be to have the quotation marks (with preceding f) automatically inserted.

Extra line when inserting at beginning of hanging indent

Minimal code example:

What the code looks like before pressing enter:

def my_example():
    x = {|
        0: 1,
    }

What I want the code to look like after pressing enter:

def my_example():
    x = {
        |
        0: 1,
    }

What the code actually looks like after pressing enter:

def my_example():
    x = {
        |
    
        0: 1,
    }

Write a short description about why you want the behavior you have described.

When inserting a new item at the beginning of a hanging-indent dictionary, I expected I could place the cursor after the opening bracket and then press return. It works correctly when placing it at the beginning of the first item, but that is a tad more difficult to achieve (sloppy mouse click to get to the end of the line, then press home).

Environment (please complete the following information):

  • Python Indent version: 1.5.0
  • Visual Studio Code version: 1.39.8
  • OS: Ubuntu 18.04

Thanks a lot for the plugin! 🎉

brain storming

am kinda in the same boat as u r, trying to hook into the enter event however i wanted to ask you

  • why not use the onDidChangeTextDocument and check for the content text instead of overriding the enter key which is used in lots of places ?
  • for the tabsize, you can instead get the previous line spaces by prevLineText.match(/^\s+/)

the ext am building https://github.com/ctf0/vscode-auto-expand-on-enter

Pressing enter to auto-fill is broken

When you're half way through typing a variable/function name and the text is ready to auto-fill, pressing Enter usually defaults to auto filling. In this is forces a new line and you're forced to only use Tab to auto fill.

I see no point where you would want a new line when the auto-fill options are up in python.
Any chance of reverting that functionality back to normal?

Leaves indented white space if pressing ENTER on a line with no text

As far as I can tell this occurs in nearly all circumstances. The only exception is for the line immediately following a return statement that ends a function. When on the line below the return statement, you TAB then press ENTER and the TAB is automatically removed.

I wouldn't classify this as a feature request since this is the default behavior of VSCode. Hopefully all that is required to implement this is to detect a non-text line and remove any white space while indenting the next line by that same amount of white space.

What the code looks like before pressing enter:

def my_example():
    |  # We decide we want an additional blank line so we will press ENTER to move down 1 line

What I want the code to look like after pressing enter:

def my_example():
# White space was removed from this line
    |

What the code actually looks like after pressing enter:

def my_example():
    # White space was left here
    |

This can be very frustrating since the alternative is to either remove the white space, press RETURN and then re-indent the new line or press ENTER type out your code and go back later and delete the white space (probably after your linter gives you a bunch of warnings).

Environment (please complete the following information):

  • Python Indent version: [e.g. 1.2.0]
  • Visual Studio Code version: [e.g. 1.36.1]
  • OS: Windows 10 1809

else: is not automatically dedented

When doing an if-else statement in python the if and the else should be on the same indention level.

This is how it looks today when doing no manual indentation

if value == True:
    print("something")
    else: 
        print("something")

This is how the expected behavior should be

if value == True:
    print("something")
else: 
    print("something")

Right now I need to manually indent the else: one step to the left.

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.