mirror of
https://github.com/cursorless-dev/cursorless.git
synced 2024-10-05 05:17:38 +03:00
Implementation of modulo line numbers (#333)
* Implementation of modulo line numbers * Cleaned up line numbers * replaced CRLF line endings * Handled folded regions * Handled folded regions * Properly handle folded regions * Normalise recorded test cases Co-authored-by: Pokey Rule <pokey.rule@gmail.com>
This commit is contained in:
parent
1aa6ce31b3
commit
514c72db37
@ -208,7 +208,8 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
if (editor == null || editor.document !== event.document) {
|
||||
return;
|
||||
}
|
||||
const { start, end } = editor.visibleRanges[0];
|
||||
const { start } = editor.visibleRanges[0];
|
||||
const { end } = editor.visibleRanges[editor.visibleRanges.length - 1];
|
||||
const ranges = [];
|
||||
for (const edit of event.contentChanges) {
|
||||
if (
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { result } from "lodash";
|
||||
import { Range, Selection } from "vscode";
|
||||
import {
|
||||
DecoratedSymbol,
|
||||
@ -151,10 +152,47 @@ function processDecoratedSymbol(
|
||||
}
|
||||
|
||||
function processLineNumber(context: ProcessedTargetsContext, mark: LineNumber) {
|
||||
const getLine = (linePosition: LineNumberPosition) =>
|
||||
linePosition.isRelative
|
||||
? context.currentEditor!.selection.active.line + linePosition.lineNumber
|
||||
: linePosition.lineNumber;
|
||||
const editor = context.currentEditor!;
|
||||
const getLine = (linePosition: LineNumberPosition) => {
|
||||
switch (linePosition.type) {
|
||||
case "absolute":
|
||||
return linePosition.lineNumber;
|
||||
case "relative":
|
||||
return editor.selection.active.line + linePosition.lineNumber;
|
||||
case "modulo100":
|
||||
const stepSize = 100;
|
||||
const startLine = editor.visibleRanges[0].start.line;
|
||||
const endLine =
|
||||
editor.visibleRanges[editor.visibleRanges.length - 1].end.line;
|
||||
const base = Math.floor(startLine / stepSize) * stepSize;
|
||||
const visibleLines = [];
|
||||
const invisibleLines = [];
|
||||
let lineNumber = base + linePosition.lineNumber;
|
||||
while (lineNumber <= endLine) {
|
||||
if (lineNumber >= startLine) {
|
||||
const visible = editor.visibleRanges.find(
|
||||
(r) => lineNumber >= r.start.line && lineNumber <= r.end.line
|
||||
);
|
||||
if (visible) {
|
||||
visibleLines.push(lineNumber);
|
||||
} else {
|
||||
invisibleLines.push(lineNumber);
|
||||
}
|
||||
}
|
||||
lineNumber += stepSize;
|
||||
}
|
||||
if (visibleLines.length === 1) {
|
||||
return visibleLines[0];
|
||||
}
|
||||
if (visibleLines.length + invisibleLines.length > 1) {
|
||||
throw new Error("Multiple lines matching");
|
||||
}
|
||||
if (invisibleLines.length === 1) {
|
||||
return invisibleLines[0];
|
||||
}
|
||||
throw new Error("Line is not in viewport");
|
||||
}
|
||||
};
|
||||
return [
|
||||
{
|
||||
selection: new Selection(
|
||||
|
@ -11,7 +11,9 @@ command:
|
||||
mark: {type: decoratedSymbol, symbolColor: default, character: h}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: " hello world\r\n value = {a:2}"
|
||||
documentContents: |2-
|
||||
hello world
|
||||
value = {a:2}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
@ -23,7 +25,9 @@ initialState:
|
||||
start: {line: 0, character: 4}
|
||||
end: {line: 0, character: 9}
|
||||
finalState:
|
||||
documentContents: " {a:2}\r\n value = {a:2}"
|
||||
documentContents: |2-
|
||||
{a:2}
|
||||
value = {a:2}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
|
@ -11,7 +11,9 @@ command:
|
||||
mark: {type: decoratedSymbol, symbolColor: default, character: h}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: " hello\r\n value = {a:2}"
|
||||
documentContents: |2-
|
||||
hello
|
||||
value = {a:2}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
@ -23,7 +25,9 @@ initialState:
|
||||
start: {line: 0, character: 4}
|
||||
end: {line: 0, character: 9}
|
||||
finalState:
|
||||
documentContents: " {a:2}\r\n value = {a:2}"
|
||||
documentContents: |2-
|
||||
{a:2}
|
||||
value = {a:2}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
|
@ -11,7 +11,9 @@ command:
|
||||
mark: {type: decoratedSymbol, symbolColor: default, character: a}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: " hello\r\n value = {a:2}"
|
||||
documentContents: |2-
|
||||
hello
|
||||
value = {a:2}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
@ -23,7 +25,9 @@ initialState:
|
||||
start: {line: 1, character: 13}
|
||||
end: {line: 1, character: 14}
|
||||
finalState:
|
||||
documentContents: " hello\r\n value = hello"
|
||||
documentContents: |2-
|
||||
hello
|
||||
value = hello
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: attribute}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "[[nodiscard]]\r\nint f(int a = 1) {\r\n}\r\n"
|
||||
documentContents: |
|
||||
[[nodiscard]]
|
||||
int f(int a = 1) {
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 9}
|
||||
active: {line: 0, character: 9}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "[[nodiscard]]\r\nint f(int a = 1) {\r\n}\r\n"
|
||||
documentContents: |
|
||||
[[nodiscard]]
|
||||
int f(int a = 1) {
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 13}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: functionName}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "int f(int a, int b) {\r\n \r\n}"
|
||||
documentContents: |-
|
||||
int f(int a, int b) {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 4}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "int f(int a, int b) {\r\n \r\n}"
|
||||
documentContents: |-
|
||||
int f(int a, int b) {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 4}
|
||||
active: {line: 0, character: 5}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: functionName}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "int C::f(int a, int b) {\r\n \r\n}"
|
||||
documentContents: |-
|
||||
int C::f(int a, int b) {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 4}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "int C::f(int a, int b) {\r\n \r\n}"
|
||||
documentContents: |-
|
||||
int C::f(int a, int b) {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 7}
|
||||
active: {line: 0, character: 8}
|
||||
|
@ -7,13 +7,23 @@ command:
|
||||
modifier: {type: containingScope, scopeType: ifStatement}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n if (true) {\r\n \r\n }\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
if (true) {
|
||||
|
||||
}
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 8}
|
||||
active: {line: 2, character: 8}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n if (true) {\r\n \r\n }\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
if (true) {
|
||||
|
||||
}
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 3, character: 5}
|
||||
|
@ -7,13 +7,23 @@ command:
|
||||
modifier: {type: containingScope, scopeType: ifStatement}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n if constexpr (true) {\r\n \r\n }\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
if constexpr (true) {
|
||||
|
||||
}
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 8}
|
||||
active: {line: 2, character: 8}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n if constexpr (true) {\r\n \r\n }\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
if constexpr (true) {
|
||||
|
||||
}
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 3, character: 5}
|
||||
|
@ -7,13 +7,25 @@ command:
|
||||
modifier: {type: containingScope, scopeType: collectionItem}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n std::vector<int> v {\r\n 1 + 2,\r\n 3\r\n };\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
std::vector<int> v {
|
||||
1 + 2,
|
||||
3
|
||||
};
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 10}
|
||||
active: {line: 2, character: 10}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n std::vector<int> v {\r\n 1 + 2,\r\n 3\r\n };\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
std::vector<int> v {
|
||||
1 + 2,
|
||||
3
|
||||
};
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 8}
|
||||
active: {line: 2, character: 13}
|
||||
|
@ -7,13 +7,25 @@ command:
|
||||
modifier: {type: containingScope, scopeType: collectionItem}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n int arr[] = {\r\n 1 + 2,\r\n 3\r\n };\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
int arr[] = {
|
||||
1 + 2,
|
||||
3
|
||||
};
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 11}
|
||||
active: {line: 2, character: 11}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n int arr[] = {\r\n 1 + 2,\r\n 3\r\n };\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
int arr[] = {
|
||||
1 + 2,
|
||||
3
|
||||
};
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 8}
|
||||
active: {line: 2, character: 13}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: anonymousFunction}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n [](){}();\r\n}\r\n"
|
||||
documentContents: |
|
||||
void f() {
|
||||
[](){}();
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 7}
|
||||
active: {line: 1, character: 7}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n [](){}();\r\n}\r\n"
|
||||
documentContents: |
|
||||
void f() {
|
||||
[](){}();
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 10}
|
||||
|
@ -7,13 +7,25 @@ command:
|
||||
modifier: {type: containingScope, scopeType: list}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n std::vector<int> v {\r\n 1 + 2,\r\n 3\r\n };\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
std::vector<int> v {
|
||||
1 + 2,
|
||||
3
|
||||
};
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 11}
|
||||
active: {line: 2, character: 11}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n std::vector<int> v {\r\n 1 + 2,\r\n 3\r\n };\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
std::vector<int> v {
|
||||
1 + 2,
|
||||
3
|
||||
};
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 23}
|
||||
active: {line: 4, character: 5}
|
||||
|
@ -7,13 +7,25 @@ command:
|
||||
modifier: {type: containingScope, scopeType: list}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n int arr[] = {\r\n 1 + 2,\r\n 3\r\n };\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
int arr[] = {
|
||||
1 + 2,
|
||||
3
|
||||
};
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 12}
|
||||
active: {line: 2, character: 12}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n int arr[] = {\r\n 1 + 2,\r\n 3\r\n };\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
int arr[] = {
|
||||
1 + 2,
|
||||
3
|
||||
};
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 16}
|
||||
active: {line: 4, character: 5}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: name}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n int i = 1;\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
int i = 1;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 13}
|
||||
active: {line: 1, character: 13}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n int i = 1;\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
int i = 1;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 8}
|
||||
active: {line: 1, character: 9}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: name}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f(int i = 1) {\r\n \r\n}"
|
||||
documentContents: |-
|
||||
void f(int i = 1) {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 15}
|
||||
active: {line: 0, character: 15}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f(int i = 1) {\r\n \r\n}"
|
||||
documentContents: |-
|
||||
void f(int i = 1) {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 11}
|
||||
active: {line: 0, character: 12}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: name}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f(int i = 1) {\r\n \r\n}"
|
||||
documentContents: |-
|
||||
void f(int i = 1) {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 4}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f(int i = 1) {\r\n \r\n}"
|
||||
documentContents: |-
|
||||
void f(int i = 1) {
|
||||
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 5}
|
||||
active: {line: 0, character: 6}
|
||||
|
@ -7,13 +7,23 @@ command:
|
||||
modifier: {type: containingScope, scopeType: statement}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n while (true) {\r\n ;\r\n }\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
while (true) {
|
||||
;
|
||||
}
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 7}
|
||||
active: {line: 1, character: 7}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n while (true) {\r\n ;\r\n }\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
while (true) {
|
||||
;
|
||||
}
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 3, character: 5}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: statement}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n a = 1;\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
a = 1;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 7}
|
||||
active: {line: 1, character: 7}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n a = 1;\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
a = 1;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 10}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: statement}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "void f() {\r\n int a = 1;\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
int a = 1;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 10}
|
||||
active: {line: 1, character: 10}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "void f() {\r\n int a = 1;\r\n}"
|
||||
documentContents: |-
|
||||
void f() {
|
||||
int a = 1;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 14}
|
||||
|
@ -7,13 +7,15 @@ command:
|
||||
modifier: {type: containingScope, scopeType: string}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "char* a = \"hello world\";\r\n"
|
||||
documentContents: |
|
||||
char* a = "hello world";
|
||||
selections:
|
||||
- anchor: {line: 0, character: 21}
|
||||
active: {line: 0, character: 21}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "char* a = \"hello world\";\r\n"
|
||||
documentContents: |
|
||||
char* a = "hello world";
|
||||
selections:
|
||||
- anchor: {line: 0, character: 10}
|
||||
active: {line: 0, character: 23}
|
||||
|
@ -7,13 +7,15 @@ command:
|
||||
modifier: {type: containingScope, scopeType: type}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "int f(int a) {}\r\n"
|
||||
documentContents: |
|
||||
int f(int a) {}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 10}
|
||||
active: {line: 0, character: 10}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "int f(int a) {}\r\n"
|
||||
documentContents: |
|
||||
int f(int a) {}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 6}
|
||||
active: {line: 0, character: 9}
|
||||
|
@ -7,13 +7,15 @@ command:
|
||||
modifier: {type: containingScope, scopeType: type}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "int f(int a) {}\r\n"
|
||||
documentContents: |
|
||||
int f(int a) {}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 14}
|
||||
active: {line: 0, character: 14}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "int f(int a) {}\r\n"
|
||||
documentContents: |
|
||||
int f(int a) {}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 3}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: type}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "int f(int a) {\r\n int j = a;\r\n}\r\n"
|
||||
documentContents: |
|
||||
int f(int a) {
|
||||
int j = a;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 13}
|
||||
active: {line: 1, character: 13}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "int f(int a) {\r\n int j = a;\r\n}\r\n"
|
||||
documentContents: |
|
||||
int f(int a) {
|
||||
int j = a;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 1, character: 7}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: value}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "int f(int a) {\r\n int j = a;\r\n}\r\n"
|
||||
documentContents: |
|
||||
int f(int a) {
|
||||
int j = a;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 5}
|
||||
active: {line: 1, character: 5}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "int f(int a) {\r\n int j = a;\r\n}\r\n"
|
||||
documentContents: |
|
||||
int f(int a) {
|
||||
int j = a;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 12}
|
||||
active: {line: 1, character: 13}
|
||||
|
@ -7,13 +7,19 @@ command:
|
||||
modifier: {type: containingScope, scopeType: value}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "int f(int a) {\r\n a = 2;\r\n}\r\n"
|
||||
documentContents: |
|
||||
int f(int a) {
|
||||
a = 2;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 5}
|
||||
active: {line: 1, character: 5}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "int f(int a) {\r\n a = 2;\r\n}\r\n"
|
||||
documentContents: |
|
||||
int f(int a) {
|
||||
a = 2;
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 8}
|
||||
active: {line: 1, character: 9}
|
||||
|
@ -7,13 +7,17 @@ command:
|
||||
modifier: {type: containingScope, scopeType: value}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "int f(int a = 1) {\r\n}\r\n"
|
||||
documentContents: |
|
||||
int f(int a = 1) {
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 11}
|
||||
active: {line: 0, character: 11}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "int f(int a = 1) {\r\n}\r\n"
|
||||
documentContents: |
|
||||
int f(int a = 1) {
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 14}
|
||||
active: {line: 0, character: 15}
|
||||
|
@ -7,13 +7,17 @@ command:
|
||||
modifier: {type: containingScope, scopeType: collectionItem}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "\r\nint[] values = {1, 2, 3};\r\n"
|
||||
documentContents: |
|
||||
|
||||
int[] values = {1, 2, 3};
|
||||
selections:
|
||||
- anchor: {line: 1, character: 16}
|
||||
active: {line: 1, character: 16}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "\r\nint[] values = {1, 2, 3};\r\n"
|
||||
documentContents: |
|
||||
|
||||
int[] values = {1, 2, 3};
|
||||
selections:
|
||||
- anchor: {line: 1, character: 16}
|
||||
active: {line: 1, character: 17}
|
||||
|
@ -7,13 +7,21 @@ command:
|
||||
modifier: {type: containingScope, scopeType: collectionItem}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "\r\n{\r\n \"foo\": \"bar\"\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": "bar"
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 9}
|
||||
active: {line: 2, character: 9}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "\r\n{\r\n \"foo\": \"bar\"\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": "bar"
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 4}
|
||||
active: {line: 2, character: 16}
|
||||
|
@ -7,13 +7,21 @@ command:
|
||||
modifier: {type: containingScope, scopeType: collectionItem}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "\r\n{\r\n \"foo\": [1, 2, 3]\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": [1, 2, 3]
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 13}
|
||||
active: {line: 2, character: 13}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "\r\n{\r\n \"foo\": [1, 2, 3]\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": [1, 2, 3]
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 12}
|
||||
active: {line: 2, character: 13}
|
||||
|
@ -7,13 +7,21 @@ command:
|
||||
modifier: {type: containingScope, scopeType: collectionKey}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "\r\n{\r\n \"foo\": \"bar\"\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": "bar"
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 10}
|
||||
active: {line: 2, character: 10}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "\r\n{\r\n \"foo\": \"bar\"\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": "bar"
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 4}
|
||||
active: {line: 2, character: 9}
|
||||
|
@ -7,13 +7,21 @@ command:
|
||||
modifier: {type: containingScope, scopeType: list}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "\r\n{\r\n \"foo\": [1, 2, 3]\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": [1, 2, 3]
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 19}
|
||||
active: {line: 2, character: 19}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "\r\n{\r\n \"foo\": [1, 2, 3]\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": [1, 2, 3]
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 11}
|
||||
active: {line: 2, character: 20}
|
||||
|
@ -7,13 +7,21 @@ command:
|
||||
modifier: {type: containingScope, scopeType: string}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "\r\n{\r\n \"foo\": \"bar\"\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": "bar"
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 12}
|
||||
active: {line: 2, character: 12}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "\r\n{\r\n \"foo\": \"bar\"\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": "bar"
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 11}
|
||||
active: {line: 2, character: 16}
|
||||
|
@ -7,13 +7,21 @@ command:
|
||||
modifier: {type: containingScope, scopeType: value}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: "\r\n{\r\n \"foo\": \"bar\"\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": "bar"
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 9}
|
||||
active: {line: 2, character: 9}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "\r\n{\r\n \"foo\": \"bar\"\r\n}\r\n"
|
||||
documentContents: |
|
||||
|
||||
{
|
||||
"foo": "bar"
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 11}
|
||||
active: {line: 2, character: 16}
|
||||
|
@ -7,8 +7,8 @@ command:
|
||||
selectionType: line
|
||||
mark:
|
||||
type: lineNumber
|
||||
anchor: {lineNumber: 1, isRelative: true}
|
||||
active: {lineNumber: 1, isRelative: true}
|
||||
anchor: {lineNumber: 1, type: relative}
|
||||
active: {lineNumber: 1, type: relative}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: |
|
||||
@ -32,4 +32,4 @@ finalState:
|
||||
thatMark:
|
||||
- anchor: {line: 1, character: 0}
|
||||
active: {line: 1, character: 28}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: 1, isRelative: true}, active: {lineNumber: 1, isRelative: true}}, insideOutsideType: inside}]
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: 1, type: relative}, active: {lineNumber: 1, type: relative}}, insideOutsideType: inside}]
|
@ -7,8 +7,8 @@ command:
|
||||
selectionType: line
|
||||
mark:
|
||||
type: lineNumber
|
||||
anchor: {lineNumber: 1, isRelative: true}
|
||||
active: {lineNumber: 3, isRelative: true}
|
||||
anchor: {lineNumber: 1, type: relative}
|
||||
active: {lineNumber: 3, type: relative}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: |
|
||||
@ -32,4 +32,4 @@ finalState:
|
||||
thatMark:
|
||||
- anchor: {line: 1, character: 0}
|
||||
active: {line: 3, character: 28}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: 1, isRelative: true}, active: {lineNumber: 3, isRelative: true}}, insideOutsideType: inside}]
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: 1, type: relative}, active: {lineNumber: 3, type: relative}}, insideOutsideType: inside}]
|
35
src/test/suite/fixtures/recorded/marks/takeRowFive.yml
Normal file
35
src/test/suite/fixtures/recorded/marks/takeRowFive.yml
Normal file
@ -0,0 +1,35 @@
|
||||
spokenForm: take row five
|
||||
languageId: typescript
|
||||
command:
|
||||
actionName: setSelection
|
||||
partialTargets:
|
||||
- type: primitive
|
||||
selectionType: line
|
||||
mark:
|
||||
type: lineNumber
|
||||
anchor: {lineNumber: 4, type: modulo100}
|
||||
active: {lineNumber: 4, type: modulo100}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: |+
|
||||
|
||||
|
||||
|
||||
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |+
|
||||
|
||||
|
||||
|
||||
|
||||
selections:
|
||||
- anchor: {line: 4, character: 0}
|
||||
active: {line: 4, character: 0}
|
||||
thatMark:
|
||||
- anchor: {line: 4, character: 0}
|
||||
active: {line: 4, character: 0}
|
||||
fullTargets: [{type: primitive, mark: {type: lineNumber, anchor: {lineNumber: 4, type: modulo100}, active: {lineNumber: 4, type: modulo100}}, selectionType: line, position: contents, insideOutsideType: inside, modifier: {type: identity}}]
|
@ -7,8 +7,8 @@ command:
|
||||
selectionType: line
|
||||
mark:
|
||||
type: lineNumber
|
||||
anchor: {lineNumber: 3, isRelative: false}
|
||||
active: {lineNumber: 3, isRelative: false}
|
||||
anchor: {lineNumber: 3, type: absolute}
|
||||
active: {lineNumber: 3, type: absolute}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: |
|
||||
@ -32,4 +32,4 @@ finalState:
|
||||
thatMark:
|
||||
- anchor: {line: 3, character: 0}
|
||||
active: {line: 3, character: 28}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: 3, isRelative: false}, active: {lineNumber: 3, isRelative: false}}, insideOutsideType: inside}]
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: 3, type: absolute}, active: {lineNumber: 3, type: absolute}}, insideOutsideType: inside}]
|
35
src/test/suite/fixtures/recorded/marks/takeRowOne.yml
Normal file
35
src/test/suite/fixtures/recorded/marks/takeRowOne.yml
Normal file
@ -0,0 +1,35 @@
|
||||
spokenForm: take row one
|
||||
languageId: typescript
|
||||
command:
|
||||
actionName: setSelection
|
||||
partialTargets:
|
||||
- type: primitive
|
||||
selectionType: line
|
||||
mark:
|
||||
type: lineNumber
|
||||
anchor: {lineNumber: 0, type: modulo100}
|
||||
active: {lineNumber: 0, type: modulo100}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: |+
|
||||
|
||||
|
||||
|
||||
|
||||
selections:
|
||||
- anchor: {line: 4, character: 0}
|
||||
active: {line: 4, character: 0}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |+
|
||||
|
||||
|
||||
|
||||
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
thatMark:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
fullTargets: [{type: primitive, mark: {type: lineNumber, anchor: {lineNumber: 0, type: modulo100}, active: {lineNumber: 0, type: modulo100}}, selectionType: line, position: contents, insideOutsideType: inside, modifier: {type: identity}}]
|
@ -7,8 +7,8 @@ command:
|
||||
selectionType: line
|
||||
mark:
|
||||
type: lineNumber
|
||||
anchor: {lineNumber: 1, isRelative: false}
|
||||
active: {lineNumber: 3, isRelative: true}
|
||||
anchor: {lineNumber: 1, type: absolute}
|
||||
active: {lineNumber: 3, type: relative}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: |
|
||||
@ -32,4 +32,4 @@ finalState:
|
||||
thatMark:
|
||||
- anchor: {line: 1, character: 0}
|
||||
active: {line: 3, character: 28}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: 1, isRelative: false}, active: {lineNumber: 3, isRelative: true}}, insideOutsideType: inside}]
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: 1, type: absolute}, active: {lineNumber: 3, type: relative}}, insideOutsideType: inside}]
|
@ -7,8 +7,8 @@ command:
|
||||
selectionType: line
|
||||
mark:
|
||||
type: lineNumber
|
||||
anchor: {lineNumber: 1, isRelative: false}
|
||||
active: {lineNumber: 3, isRelative: false}
|
||||
anchor: {lineNumber: 1, type: absolute}
|
||||
active: {lineNumber: 3, type: absolute}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: |
|
||||
@ -32,4 +32,4 @@ finalState:
|
||||
thatMark:
|
||||
- anchor: {line: 1, character: 0}
|
||||
active: {line: 3, character: 28}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: 1, isRelative: false}, active: {lineNumber: 3, isRelative: false}}, insideOutsideType: inside}]
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: 1, type: absolute}, active: {lineNumber: 3, type: absolute}}, insideOutsideType: inside}]
|
@ -7,8 +7,8 @@ command:
|
||||
selectionType: line
|
||||
mark:
|
||||
type: lineNumber
|
||||
anchor: {lineNumber: -1, isRelative: true}
|
||||
active: {lineNumber: 1, isRelative: true}
|
||||
anchor: {lineNumber: -1, type: relative}
|
||||
active: {lineNumber: 1, type: relative}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: |
|
||||
@ -32,4 +32,4 @@ finalState:
|
||||
thatMark:
|
||||
- anchor: {line: 1, character: 0}
|
||||
active: {line: 3, character: 28}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: -1, isRelative: true}, active: {lineNumber: 1, isRelative: true}}, insideOutsideType: inside}]
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: -1, type: relative}, active: {lineNumber: 1, type: relative}}, insideOutsideType: inside}]
|
@ -7,8 +7,8 @@ command:
|
||||
selectionType: line
|
||||
mark:
|
||||
type: lineNumber
|
||||
anchor: {lineNumber: -1, isRelative: true}
|
||||
active: {lineNumber: 3, isRelative: false}
|
||||
anchor: {lineNumber: -1, type: relative}
|
||||
active: {lineNumber: 3, type: absolute}
|
||||
extraArgs: []
|
||||
initialState:
|
||||
documentContents: |
|
||||
@ -32,4 +32,4 @@ finalState:
|
||||
thatMark:
|
||||
- anchor: {line: 1, character: 0}
|
||||
active: {line: 3, character: 28}
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: -1, isRelative: true}, active: {lineNumber: 3, isRelative: false}}, insideOutsideType: inside}]
|
||||
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: line, position: contents, modifier: {type: lineNumber, anchor: {lineNumber: -1, type: relative}, active: {lineNumber: 3, type: absolute}}, insideOutsideType: inside}]
|
@ -44,9 +44,11 @@ export interface DecoratedSymbol {
|
||||
character: string;
|
||||
}
|
||||
|
||||
export type LineNumberType = "absolute" | "relative" | "modulo100";
|
||||
|
||||
export interface LineNumberPosition {
|
||||
type: LineNumberType;
|
||||
lineNumber: number;
|
||||
isRelative: boolean;
|
||||
}
|
||||
|
||||
export interface LineNumber {
|
||||
|
Loading…
Reference in New Issue
Block a user