From 3f0fcd4deeef9cb9a475925b9ae213d3c26bd370 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 29 Nov 2023 15:42:10 +0100 Subject: [PATCH] Improve item --- .../recorded/languages/yaml/changeMap2.yml | 25 ++++++ .../recorded/languages/yaml/chuckItem.yml | 28 +++++++ .../recorded/languages/yaml/chuckItem2.yml | 28 +++++++ .../recorded/languages/yaml/chuckItem3.yml | 23 ++++++ .../recorded/languages/yaml/chuckItem4.yml | 23 ++++++ .../recorded/languages/yaml/chuckItem5.yml | 25 ++++++ .../recorded/languages/yaml/chuckItem6.yml | 25 ++++++ .../recorded/languages/yaml/chuckItem7.yml | 25 ++++++ .../recorded/languages/yaml/chuckItem8.yml | 25 ++++++ queries/yaml.scm | 77 ++++++++++++------- 10 files changed, 275 insertions(+), 29 deletions(-) create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/changeMap2.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem2.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem3.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem4.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem5.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem6.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem7.yml create mode 100644 packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem8.yml diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/changeMap2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/changeMap2.yml new file mode 100644 index 0000000000..8811b7de67 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/changeMap2.yml @@ -0,0 +1,25 @@ +languageId: yaml +command: + version: 6 + spokenForm: change map + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: map} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + foo: 0 + bar: 1 + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem.yml new file mode 100644 index 0000000000..dc2d58acbd --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem.yml @@ -0,0 +1,28 @@ +languageId: yaml +command: + version: 6 + spokenForm: chuck item + action: + name: remove + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + values: + - 0 + - 1 + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +finalState: + documentContents: |- + values: + - 1 + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem2.yml new file mode 100644 index 0000000000..4026297556 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem2.yml @@ -0,0 +1,28 @@ +languageId: yaml +command: + version: 6 + spokenForm: chuck item + action: + name: remove + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + values: + - 0 + - 1 + selections: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} + marks: {} +finalState: + documentContents: |- + values: + - 0 + selections: + - anchor: {line: 1, character: 7} + active: {line: 1, character: 7} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem3.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem3.yml new file mode 100644 index 0000000000..10a428d5c2 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem3.yml @@ -0,0 +1,23 @@ +languageId: yaml +command: + version: 6 + spokenForm: chuck item + action: + name: remove + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: "values: [0, 1]" + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} + marks: {} +finalState: + documentContents: "values: [1]" + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem4.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem4.yml new file mode 100644 index 0000000000..8db772570a --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem4.yml @@ -0,0 +1,23 @@ +languageId: yaml +command: + version: 6 + spokenForm: chuck item + action: + name: remove + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: "values: [0, 1]" + selections: + - anchor: {line: 0, character: 13} + active: {line: 0, character: 13} + marks: {} +finalState: + documentContents: "values: [0]" + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem5.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem5.yml new file mode 100644 index 0000000000..b90ab39977 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem5.yml @@ -0,0 +1,25 @@ +languageId: yaml +command: + version: 6 + spokenForm: chuck item + action: + name: remove + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + foo: 0 + bar: 0 + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "bar: 0" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem6.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem6.yml new file mode 100644 index 0000000000..1c2f2c0d48 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem6.yml @@ -0,0 +1,25 @@ +languageId: yaml +command: + version: 6 + spokenForm: chuck item + action: + name: remove + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + foo: 0 + bar: 0 + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + marks: {} +finalState: + documentContents: "foo: 0" + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem7.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem7.yml new file mode 100644 index 0000000000..e40b110740 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem7.yml @@ -0,0 +1,25 @@ +languageId: yaml +command: + version: 6 + spokenForm: chuck item + action: + name: remove + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: | + values: {foo: 0, bar: 0} + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} + marks: {} +finalState: + documentContents: | + values: {bar: 0} + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem8.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem8.yml new file mode 100644 index 0000000000..4d2203e19b --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/yaml/chuckItem8.yml @@ -0,0 +1,25 @@ +languageId: yaml +command: + version: 6 + spokenForm: chuck item + action: + name: remove + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionItem} + usePrePhraseSnapshot: true +initialState: + documentContents: | + values: {foo: 0, bar: 0} + selections: + - anchor: {line: 0, character: 17} + active: {line: 0, character: 17} + marks: {} +finalState: + documentContents: | + values: {foo: 0} + selections: + - anchor: {line: 0, character: 15} + active: {line: 0, character: 15} diff --git a/queries/yaml.scm b/queries/yaml.scm index ce14c65559..0a3b9148ce 100644 --- a/queries/yaml.scm +++ b/queries/yaml.scm @@ -1,13 +1,56 @@ -;;!! foo: bar -;;! ^^^ ^^^ +;; ;;!! foo: bar +;; ;;! ^^^ ^^^ (_ key: (_) @collectionKey @collectionKey.trailing.start.endOf @value.leading.start.endOf value: (_) @value @collectionKey.trailing.start.startOf @value.leading.start.startOf -) @collectionItem @_.domain +) @_.domain + +;;!! foo: bar +;;! ^^^^^^^^ +(block_mapping + (block_mapping_pair)? @collectionItem.leading.start.endOf + . + (block_mapping_pair) @collectionItem @collectionItem.leading.end.startOf @collectionItem.trailing.end.endOf + . + (block_mapping_pair)? @collectionItem.trailing.end.startOf +) @map + +;;!! - 0 +;;! ^^^ +(block_sequence + (block_sequence_item)? @collectionItem.leading.start.endOf + . + (block_sequence_item) @collectionItem @collectionItem.leading.end.startOf @collectionItem.trailing.end.endOf + . + (block_sequence_item)? @collectionItem.trailing.end.startOf +) @list + +;;!! [0] +;;! ^ +(flow_sequence + (flow_node)? @collectionItem.leading.start.endOf + . + (flow_node) @collectionItem @collectionItem.leading.end.startOf @collectionItem.trailing.end.endOf + . + (flow_node)? @collectionItem.trailing.end.startOf +) @list -(block_mapping) @collectionItem.iteration @collectionKey.iteration @value.iteration +;;!! { foo: bar } +;;! ^^^^^^^^ +(flow_mapping + (flow_pair)? @collectionItem.leading.start.endOf + . + (flow_pair) @collectionItem @collectionItem.leading.end.startOf @collectionItem.trailing.end.endOf + . + (flow_pair)? @collectionItem.trailing.end.startOf +) @map -(flow_pair) @collectionItem +[ + (block_mapping) + (block_sequence) + (flow_sequence) + (flow_mapping) +] @collectionItem.iteration @collectionKey.iteration @value.iteration ;;!! languageId: plauintext ;;! ^^^^^^^^^^ @@ -19,27 +62,3 @@ ;;!! | block scalar (block_scalar) @textFragment - -;;!! { foo: bar } -;;! ^^^^^^^^^^^^ -(flow_mapping) @map -(flow_mapping) @collectionItem.iteration @collectionKey.iteration @value.iteration - -[ - ;;!! - 0\n- 1 - ;;! ^^^^^^^^ - (block_sequence) - ;;!! [0, 1] - ;;! ^^^^^^ - (flow_sequence) -] @list @collectionItem.iteration - -;;!! - 0 -;;! ^^^ -(block_sequence_item) @collectionItem - -;;!! [0] -;;! ^ -(flow_sequence - (flow_node) @collectionItem -)