-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle trailing commas in python arguments
- Loading branch information
1 parent
ab072ee
commit 97adc6b
Showing
11 changed files
with
130 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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; | ||
} |
5 changes: 5 additions & 0 deletions
5
...es/cursorless-engine/src/processTargets/modifiers/scopeHandlers/util/isHintsEveryScope.ts
This file contains 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,5 @@ | ||
import type { ScopeIteratorRequirements } from "../scopeHandler.types"; | ||
|
||
export function isHintsEveryScope(hints: ScopeIteratorRequirements): boolean { | ||
return hints.containment == null && hints.skipAncestorScopes; | ||
} |
This file contains 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