forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Drop dedent-on-enter for "return" statements. #6939
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
Merged
ericsnowcurrently
merged 21 commits into
microsoft:master
from
ericsnowcurrently:drop-return-dedent
Aug 13, 2019
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b8ae859
Revert "Revert "Add regex to dedent `else` and friends (#6497)" (#6945)"
ericsnowcurrently 9b94f35
Copy IndentAction into the mock VSCode.
ericsnowcurrently 319dd87
Test against getLanguageConfiguration().
ericsnowcurrently d1da292
language config formatting
ericsnowcurrently 9add75c
Inline the regexes.
ericsnowcurrently 465147f
Add a verboseRegExp() helper.
ericsnowcurrently e90bcbb
Use verbose regexes in the language config.
ericsnowcurrently 09f4110
Make the regex tests a little easier to read/modify.
ericsnowcurrently cbbb419
Correct the break/continue/return regex.
ericsnowcurrently 0ccf9cd
Fill in language config regex test coverage.
ericsnowcurrently 02cee4b
Minor fixes to language config regex patterns.
ericsnowcurrently cc055fe
Drop support for indent-on-enter for "return *".
ericsnowcurrently c20ea1c
Drop indent-on-enter for "return" completely.
ericsnowcurrently 1ff16dc
Drop an erroneous test.
ericsnowcurrently b630586
Add a NEWS entry.
ericsnowcurrently 395442f
Add tests for verboseRegExp().
ericsnowcurrently dea0c9a
Move indentationRules back to onEnterRules.
ericsnowcurrently ad4a4be
Move a comment.
ericsnowcurrently 15d1ff2
Add a doc comment for verboseRegExp().
ericsnowcurrently 5632014
Clarify the objective of a test.
ericsnowcurrently 611b126
Move the language configuration test suites into a parent suite.
ericsnowcurrently File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Drop dedent-on-enter for "return" statements. It will be addressed in: | ||
https://github.com/microsoft/vscode-python/issues/6564 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
/* Generate a RegExp from a "verbose" pattern. | ||
* | ||
* All whitespace in the pattern is removed, including newlines. This | ||
* allows the pattern to be much more readable by allowing it to span | ||
* multiple lines and to separate tokens with insignificant whitespace. | ||
* The functionality is similar to the VERBOSE ("x") flag in Python's | ||
* regular expressions. | ||
* | ||
* Note that significant whitespace in the pattern must be explicitly | ||
* indicated by "\s". Also, unlike with regular expression literals, | ||
* backslashes must be escaped. Conversely, forward slashes do not | ||
* need to be escaped. | ||
*/ | ||
export function verboseRegExp(pattern: string): RegExp { | ||
pattern = pattern.replace(/\s+?/g, ''); | ||
return RegExp(pattern); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
// tslint:disable:no-multiline-string | ||
|
||
import { expect } from 'chai'; | ||
|
||
import { | ||
verboseRegExp | ||
} from '../../../client/common/utils/regexp'; | ||
|
||
suite('Utils for regular expressions - verboseRegExp()', () => { | ||
test('whitespace removed in multiline pattern (example of typical usage)', () => { | ||
const regex = verboseRegExp(` | ||
^ | ||
(?: | ||
spam \\b .* | ||
) | | ||
(?: | ||
eggs \\b .* | ||
) | ||
$ | ||
`); | ||
|
||
expect(regex.source).to.equal('^(?:spam\\b.*)|(?:eggs\\b.*)$', 'mismatch'); | ||
}); | ||
|
||
const whitespaceTests = [ | ||
['spam eggs', 'spameggs'], | ||
[`spam | ||
eggs`, 'spameggs'], | ||
// empty | ||
[' ', '(?:)'], | ||
[` | ||
`, '(?:)'] | ||
]; | ||
for (const [pat, expected] of whitespaceTests) { | ||
test(`whitespace removed ("${pat}")`, () => { | ||
const regex = verboseRegExp(pat); | ||
|
||
expect(regex.source).to.equal(expected, 'mismatch'); | ||
}); | ||
} | ||
|
||
const noopPatterns = [ | ||
'^(?:spam\\b.*)$', | ||
'spam', | ||
'^spam$', | ||
'spam$', | ||
'^spam' | ||
]; | ||
for (const pat of noopPatterns) { | ||
test(`pattern not changed ("${pat}")`, () => { | ||
const regex = verboseRegExp(pat); | ||
|
||
expect(regex.source).to.equal(pat, 'mismatch'); | ||
}); | ||
} | ||
|
||
const emptyPatterns = [ | ||
'', | ||
` | ||
`, | ||
' ' | ||
]; | ||
for (const pat of emptyPatterns) { | ||
test(`no pattern ("${pat}")`, () => { | ||
const regex = verboseRegExp(pat); | ||
|
||
expect(regex.source).to.equal('(?:)', 'mismatch'); | ||
}); | ||
} | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.