-
-
Notifications
You must be signed in to change notification settings - Fork 91
Properly handle trailing commas in python arguments #2780
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
Merged
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
97adc6b
Properly handle trailing commas in python arguments
AndreasArvidsson 2033b64
comment
AndreasArvidsson 63847e9
rename
AndreasArvidsson 07371d1
Update packages/cursorless-engine/src/processTargets/modifiers/scopeH…
phillco 64659ed
rename
AndreasArvidsson 172f7e9
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 34b22e2
merch
AndreasArvidsson 432b71a
merch
AndreasArvidsson 32eb477
Merge branch 'main' into pythonArguments
AndreasArvidsson b9c65c2
Update packages/cursorless-engine/src/processTargets/modifiers/scopeH…
phillco f7b6f8c
Update packages/cursorless-engine/src/processTargets/modifiers/scopeH…
phillco 0fcb122
Update packages/cursorless-engine/src/processTargets/modifiers/scopeH…
phillco d212a20
Doc string
AndreasArvidsson 8fd363d
Merge branch 'pythonArguments' of github.com:cursorless-dev/cursorles…
AndreasArvidsson a77845d
Update packages/cursorless-engine/src/processTargets/modifiers/scopeH…
phillco 5390679
Refactor
AndreasArvidsson 97ea33a
Merge branch 'pythonArguments' of github.com:cursorless-dev/cursorles…
AndreasArvidsson b122965
fix
AndreasArvidsson 45ee6a6
Update packages/cursorless-engine/src/processTargets/modifiers/scopeH…
phillco e0a02ab
Update packages/cursorless-engine/src/processTargets/modifiers/scopeH…
phillco e272358
Update packages/cursorless-engine/src/processTargets/modifiers/scopeH…
phillco 5a5a723
Update packages/cursorless-engine/src/processTargets/modifiers/scopeH…
phillco 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,49 @@ | ||
def foo( | ||
aaa, | ||
bbb, | ||
): | ||
pass | ||
--- | ||
|
||
[#1 Content] = | ||
[#1 Domain] = 1:4-1:7 | ||
>---< | ||
1| aaa, | ||
|
||
[#1 Removal] = 1:4-2:4 | ||
>---- | ||
1| aaa, | ||
2| bbb, | ||
----< | ||
|
||
[#1 Trailing delimiter] = 1:7-2:4 | ||
>- | ||
1| aaa, | ||
2| bbb, | ||
----< | ||
|
||
[#1 Insertion delimiter] = ",\n" | ||
|
||
|
||
[#2 Content] = | ||
[#2 Domain] = 2:4-2:7 | ||
>---< | ||
2| bbb, | ||
|
||
[#2 Removal] = 1:7-2:7 | ||
>- | ||
1| aaa, | ||
2| bbb, | ||
-------< | ||
|
||
[#2 Leading delimiter] = 1:7-2:4 | ||
>- | ||
1| aaa, | ||
2| bbb, | ||
----< | ||
|
||
[#2 Trailing delimiter] = 2:7-2:8 | ||
>-< | ||
2| bbb, | ||
|
||
[#2 Insertion delimiter] = ",\n" |
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
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
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
22 changes: 22 additions & 0 deletions
22
...s-engine/src/processTargets/modifiers/scopeHandlers/util/getCollectionItemRemovalRange.ts
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 @@ | ||
import type { Range, TextEditor } from "@cursorless/common"; | ||
|
||
import { getRangeLength } from "../../../../util/rangeUtils"; | ||
|
||
export function getCollectionItemRemovalRange( | ||
isEveryScope: boolean, | ||
editor: TextEditor, | ||
contentRange: Range, | ||
leadingDelimiterRange: Range | undefined, | ||
trailingDelimiterRange: Range | undefined, | ||
): Range | undefined { | ||
// We have both leading and trailing delimiter ranges | ||
// If the leading one is longer/more specific, prefer to use that for removal; | ||
// otherwise use undefined to fallback to the default behavior (often trailing) | ||
|
||
return !isEveryScope && | ||
leadingDelimiterRange != null && | ||
trailingDelimiterRange != null && | ||
getRangeLength(editor, leadingDelimiterRange) > | ||
getRangeLength(editor, trailingDelimiterRange) | ||
? contentRange.union(leadingDelimiterRange) | ||
: undefined; | ||
} |
8 changes: 8 additions & 0 deletions
8
...es/cursorless-engine/src/processTargets/modifiers/scopeHandlers/util/isHintsEveryScope.ts
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,8 @@ | ||||||
import type { ScopeIteratorRequirements } from "../scopeHandler.types"; | ||||||
|
||||||
/** | ||||||
* Returns true if the hints belong to the every scope modifier. | ||||||
phillco marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
*/ | ||||||
export function isHintsEveryScope(hints: ScopeIteratorRequirements): boolean { | ||||||
|
export function isHintsEveryScope(hints: ScopeIteratorRequirements): boolean { | |
export function isEveryScope(hints: ScopeIteratorRequirements): boolean { |
phillco marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
phillco marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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
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.