-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parenthesis wrapping after raise
is wrong
#10583
Comments
We have a bigger indentation work item #8996 that covers a lot of issues. |
Closing in favour of #8996. |
Having coincidentally hit this again earlier today, I've just had a look into why this happens. It looks like this is a result of the vscode-python/src/client/language/languageConfiguration.ts Lines 77 to 105 in 92e66a0
Essentially, the rule is configured to cope with either if False:
raise Foo| or if False:
raise Foo(...)| cases, but not the case reported above: if False:
raise Foo(|) Personally I would happily trade off having the I realise that #8996 exists with a goal of a more complete solution, however that's been the case for a considerable time without any movement and it sounds like the approach being explored there is a much more complete auto-formatter which is likely to have side effects beyond fixing this sort of cursor-positioning/indent issue and may put off people (myself included) who do not like auto-formatters. @luabud would you consider a PR to flip the trade-off as I've described above? |
Cross linking: looks like #10285 is another instance of exactly this case. |
@PeterJCLaw, about this:
My concern is that a lot of people may not feel the same way. I personally prefer to add spaces than deleting it (I guess it's mostly because that's what I got used to do 😅) . I wouldn't be reluctant to accept this change if it only impacts In any case I'm reopening this and marking as "needs decision" so I can talk to the team about this 😊 |
Thanks! One additional data-point I've spotted now that I've been thinking about this is that if False:
return foo(|) becomes if False:
return foo(
|
) and if False:
return foo| becomes if False:
return foo
| I agree that the current behaviour makes sense for |
@PeterJCLaw I talked to the team and everyone was ok with a PR for the change for raise 😊 |
This changes the behaviour of pressing enter after a raise statement which involves an explicit value so that the cursor position is no longer outdented. Previosly this worked well for things like: raise raise e but less well for things like: raise Exception(|) which wouuld end up like: raise Exception( |) With this change applied the latter case will end up like: raise Exception( | ) which matches the behaviour of 'return'. The first case (without a value) is unaffected, though the case of: raise e will, just like 'return' now require the user to explicitly outdent after pressing enter. It is expected that this is an accpetable trade-off, especially as it is alrady the case for return statements. Fixes microsoft#10583.
This changes the behaviour of pressing enter after a raise statement which involves an explicit value so that the cursor position is no longer outdented. Previously this worked well for things like: raise raise e but less well for things like: raise Exception(|) which wouuld end up like: raise Exception( |) With this change applied the latter case will end up like: raise Exception( | ) which matches the behaviour of 'return'. The first case (without a value) is unaffected, though the case of: raise e will, just like 'return' now require the user to explicitly outdent after pressing enter. It is expected that this is an accpetable trade-off, especially as it is alrady the case for return statements. Fixes microsoft#10583.
This changes the behaviour of pressing enter after a raise statement which involves an explicit value so that the cursor position is no longer outdented. Previously this worked well for things like: raise raise e but less well for things like: raise Exception(|) which wouuld end up like: raise Exception( |) With this change applied the latter case will end up like: raise Exception( | ) which matches the behaviour of 'return'. The first case (without a value) is unaffected, though the case of: raise e will, just like 'return' now require the user to explicitly outdent after pressing enter. It is expected that this is an acceptable trade-off, especially as it is already the case for return statements. Fixes microsoft#10583.
This changes the behaviour of pressing enter after a raise statement which involves an explicit value so that the cursor position is no longer outdented. Previously this worked well for things like: raise raise e but less well for things like: raise Exception(|) which wouuld end up like: raise Exception( |) With this change applied the latter case will end up like: raise Exception( | ) which matches the behaviour of 'return'. The first case (without a value) is unaffected, though the case of: raise e will, just like 'return' now require the user to explicitly outdent after pressing enter. It is expected that this is an acceptable trade-off, especially as it is already the case for return statements. Fixes microsoft#10583.
This changes the behaviour of pressing enter after a raise statement which involves an explicit value so that the cursor position is no longer outdented. Previously this worked well for things like: raise raise e but less well for things like: raise Exception(|) which wouuld end up like: raise Exception( |) With this change applied the latter case will end up like: raise Exception( | ) which matches the behaviour of 'return'. The first case (without a value) is unaffected, though the case of: raise e will, just like 'return' now require the user to explicitly outdent after pressing enter. It is expected that this is an acceptable trade-off, especially as it is already the case for return statements. Fixes #10583.
Environment data
python.languageServer
setting: MicrosoftExpected behaviour
Given code like this:
Then pressing return with the cursor between the parentheses should wrap the code as so:
This is what you get if either there isn't a
raise
keyword present or if it isreturn
insteadActual behaviour
Given code like this:
Then pressing return with the cursor between the parentheses actually wraps to:
The text was updated successfully, but these errors were encountered: