Skip to content

Commit

Permalink
Fixed bug with array in pair value (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson authored Aug 16, 2021
1 parent 7a10719 commit 0e67a27
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/languages/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const nodeMatchers: Partial<Record<ScopeType, NodeMatcherAlternative>> = {
"*[name]",
],
collectionItem: argumentMatcher(...dictionaryTypes, ...listTypes),
value: valueMatcher("assignment[right]", "*[value]"),
value: valueMatcher("assignment[right]", "pair[value].*", "*[value]"),
argumentOrParameter: argumentMatcher("parameters", "argument_list"),
};

Expand Down
10 changes: 5 additions & 5 deletions src/nodeSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export function selectWithLeadingDelimiter(
editor: TextEditor,
node: SyntaxNode
): SelectionWithContext {
const leadingDelimiterToken = node.previousSibling!;
const leadingDelimiterToken = node.previousSibling;

const leadingDelimiterRange = makeRange(
leadingDelimiterToken.startPosition,
node.startPosition
);
const leadingDelimiterRange =
leadingDelimiterToken != null
? makeRange(leadingDelimiterToken.startPosition, node.startPosition)
: null;

return {
...simpleSelectionExtractor(editor, node),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
spokenForm: take value zero
languageId: python
command:
actionName: setSelection
partialTargets:
- type: primitive
modifier: {type: containingScope, scopeType: value, includeSiblings: false}
mark: {type: decoratedSymbol, symbolColor: default, character: '0'}
extraArgs: []
marks:
default.0:
start: {line: 1, character: 15}
end: {line: 1, character: 16}
initialState:
documentContents: |-
{
"foo": bar[0]
}
selections:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
finalState:
documentContents: |-
{
"foo": bar[0]
}
selections:
- anchor: {line: 1, character: 11}
active: {line: 1, character: 17}
thatMark:
- anchor: {line: 1, character: 11}
active: {line: 1, character: 17}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: '0'}, selectionType: token, position: contents, modifier: {type: containingScope, scopeType: value, includeSiblings: false}, insideOutsideType: inside}]

0 comments on commit 0e67a27

Please sign in to comment.