diff --git a/src/extension.ts b/src/extension.ts index 5dedda004..612076a21 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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 ( diff --git a/src/processTargets/processMark.ts b/src/processTargets/processMark.ts index 64f4efa72..acbf5f5c3 100644 --- a/src/processTargets/processMark.ts +++ b/src/processTargets/processMark.ts @@ -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( diff --git a/src/test/suite/fixtures/recorded/inference/bringMapAirToLineHarp.yml b/src/test/suite/fixtures/recorded/inference/bringMapAirToLineHarp.yml index 70eb2e7bd..c9811b41e 100644 --- a/src/test/suite/fixtures/recorded/inference/bringMapAirToLineHarp.yml +++ b/src/test/suite/fixtures/recorded/inference/bringMapAirToLineHarp.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/inference/bringMapAirToTokenHarp.yml b/src/test/suite/fixtures/recorded/inference/bringMapAirToTokenHarp.yml index edba8b54c..69c2b584f 100644 --- a/src/test/suite/fixtures/recorded/inference/bringMapAirToTokenHarp.yml +++ b/src/test/suite/fixtures/recorded/inference/bringMapAirToTokenHarp.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/inference/bringTokenHarpToMapAir.yml b/src/test/suite/fixtures/recorded/inference/bringTokenHarpToMapAir.yml index d424cf209..4a782e5cf 100644 --- a/src/test/suite/fixtures/recorded/inference/bringTokenHarpToMapAir.yml +++ b/src/test/suite/fixtures/recorded/inference/bringTokenHarpToMapAir.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeAttribute.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeAttribute.yml index f45458ef2..879915f1b 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeAttribute.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeAttribute.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeFunkName.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeFunkName.yml index 7d09b3678..4842280ed 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeFunkName.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeFunkName.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeFunkName2.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeFunkName2.yml index d96902d74..f2327971d 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeFunkName2.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeFunkName2.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeIf.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeIf.yml index 02ad3557b..84ffbf778 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeIf.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeIf.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeIf2.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeIf2.yml index abc41180c..a90cd67da 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeIf2.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeIf2.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeItem.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeItem.yml index e8fbada77..5a1a89212 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeItem.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeItem.yml @@ -7,13 +7,25 @@ command: modifier: {type: containingScope, scopeType: collectionItem} extraArgs: [] initialState: - documentContents: "void f() {\r\n std::vector v {\r\n 1 + 2,\r\n 3\r\n };\r\n}" + documentContents: |- + void f() { + std::vector v { + 1 + 2, + 3 + }; + } selections: - anchor: {line: 2, character: 10} active: {line: 2, character: 10} marks: {} finalState: - documentContents: "void f() {\r\n std::vector v {\r\n 1 + 2,\r\n 3\r\n };\r\n}" + documentContents: |- + void f() { + std::vector v { + 1 + 2, + 3 + }; + } selections: - anchor: {line: 2, character: 8} active: {line: 2, character: 13} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeItem2.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeItem2.yml index 32d4e8c1d..212cf9c90 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeItem2.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeItem2.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeLambda.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeLambda.yml index 41db22137..41beb7a69 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeLambda.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeLambda.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeList.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeList.yml index 9db908dac..db9cdf616 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeList.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeList.yml @@ -7,13 +7,25 @@ command: modifier: {type: containingScope, scopeType: list} extraArgs: [] initialState: - documentContents: "void f() {\r\n std::vector v {\r\n 1 + 2,\r\n 3\r\n };\r\n}" + documentContents: |- + void f() { + std::vector v { + 1 + 2, + 3 + }; + } selections: - anchor: {line: 2, character: 11} active: {line: 2, character: 11} marks: {} finalState: - documentContents: "void f() {\r\n std::vector v {\r\n 1 + 2,\r\n 3\r\n };\r\n}" + documentContents: |- + void f() { + std::vector v { + 1 + 2, + 3 + }; + } selections: - anchor: {line: 1, character: 23} active: {line: 4, character: 5} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeList2.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeList2.yml index ec783c92c..b8eb8f047 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeList2.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeList2.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeName.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeName.yml index ff170f51a..d8f9c016b 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeName.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeName.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeName2.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeName2.yml index 84c351296..a68c00802 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeName2.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeName2.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeName3.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeName3.yml index 27fa97c1d..627e1d603 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeName3.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeName3.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeState.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeState.yml index b134cf072..2bcb3254b 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeState.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeState.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeState2.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeState2.yml index 8e8d2e407..9a90c967f 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeState2.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeState2.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeState3.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeState3.yml index a3ce6c2b4..80108f8b5 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeState3.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeState3.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeString.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeString.yml index 66b68a9c2..b65f37744 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeString.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeString.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeType.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeType.yml index 590fd2389..12995db16 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeType.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeType.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeType2.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeType2.yml index 685f8c8fb..b9b589184 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeType2.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeType2.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeType3.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeType3.yml index 56a9433c2..5a09b52d0 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeType3.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeType3.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeValue.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeValue.yml index 225de7cf4..8e2ad63ec 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeValue.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeValue.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeValue2.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeValue2.yml index 896e60446..e3f37d055 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeValue2.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeValue2.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/cpp/takeValue3.yml b/src/test/suite/fixtures/recorded/languages/cpp/takeValue3.yml index c8de3737e..5dafc6716 100644 --- a/src/test/suite/fixtures/recorded/languages/cpp/takeValue3.yml +++ b/src/test/suite/fixtures/recorded/languages/cpp/takeValue3.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/java/takeItem.yml b/src/test/suite/fixtures/recorded/languages/java/takeItem.yml index 10ada21e4..2763cf760 100644 --- a/src/test/suite/fixtures/recorded/languages/java/takeItem.yml +++ b/src/test/suite/fixtures/recorded/languages/java/takeItem.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/json/takeItem.yml b/src/test/suite/fixtures/recorded/languages/json/takeItem.yml index 383202b58..b1f4c193e 100644 --- a/src/test/suite/fixtures/recorded/languages/json/takeItem.yml +++ b/src/test/suite/fixtures/recorded/languages/json/takeItem.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/json/takeItem2.yml b/src/test/suite/fixtures/recorded/languages/json/takeItem2.yml index 621a78b1d..e596c3543 100644 --- a/src/test/suite/fixtures/recorded/languages/json/takeItem2.yml +++ b/src/test/suite/fixtures/recorded/languages/json/takeItem2.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/json/takeKey.yml b/src/test/suite/fixtures/recorded/languages/json/takeKey.yml index 94c647655..e1f7d706e 100644 --- a/src/test/suite/fixtures/recorded/languages/json/takeKey.yml +++ b/src/test/suite/fixtures/recorded/languages/json/takeKey.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/json/takeList.yml b/src/test/suite/fixtures/recorded/languages/json/takeList.yml index d604ec20e..d52adb14f 100644 --- a/src/test/suite/fixtures/recorded/languages/json/takeList.yml +++ b/src/test/suite/fixtures/recorded/languages/json/takeList.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/json/takeString.yml b/src/test/suite/fixtures/recorded/languages/json/takeString.yml index e6050d297..8ad0f1ebb 100644 --- a/src/test/suite/fixtures/recorded/languages/json/takeString.yml +++ b/src/test/suite/fixtures/recorded/languages/json/takeString.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/languages/json/takeValue.yml b/src/test/suite/fixtures/recorded/languages/json/takeValue.yml index 96d4a9d2e..2d097f6b5 100644 --- a/src/test/suite/fixtures/recorded/languages/json/takeValue.yml +++ b/src/test/suite/fixtures/recorded/languages/json/takeValue.yml @@ -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} diff --git a/src/test/suite/fixtures/recorded/lineNumbers/takeDownOne.yml b/src/test/suite/fixtures/recorded/marks/takeDownOne.yml similarity index 79% rename from src/test/suite/fixtures/recorded/lineNumbers/takeDownOne.yml rename to src/test/suite/fixtures/recorded/marks/takeDownOne.yml index 3aa62d160..57e1860d4 100644 --- a/src/test/suite/fixtures/recorded/lineNumbers/takeDownOne.yml +++ b/src/test/suite/fixtures/recorded/marks/takeDownOne.yml @@ -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}] diff --git a/src/test/suite/fixtures/recorded/lineNumbers/takeDownOnePastThree.yml b/src/test/suite/fixtures/recorded/marks/takeDownOnePastThree.yml similarity index 79% rename from src/test/suite/fixtures/recorded/lineNumbers/takeDownOnePastThree.yml rename to src/test/suite/fixtures/recorded/marks/takeDownOnePastThree.yml index fe120fd6c..da363afe6 100644 --- a/src/test/suite/fixtures/recorded/lineNumbers/takeDownOnePastThree.yml +++ b/src/test/suite/fixtures/recorded/marks/takeDownOnePastThree.yml @@ -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}] diff --git a/src/test/suite/fixtures/recorded/marks/takeRowFive.yml b/src/test/suite/fixtures/recorded/marks/takeRowFive.yml new file mode 100644 index 000000000..8de57dc56 --- /dev/null +++ b/src/test/suite/fixtures/recorded/marks/takeRowFive.yml @@ -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}}] diff --git a/src/test/suite/fixtures/recorded/lineNumbers/takeRowFour.yml b/src/test/suite/fixtures/recorded/marks/takeRowFour.yml similarity index 79% rename from src/test/suite/fixtures/recorded/lineNumbers/takeRowFour.yml rename to src/test/suite/fixtures/recorded/marks/takeRowFour.yml index 024264656..91b650414 100644 --- a/src/test/suite/fixtures/recorded/lineNumbers/takeRowFour.yml +++ b/src/test/suite/fixtures/recorded/marks/takeRowFour.yml @@ -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}] diff --git a/src/test/suite/fixtures/recorded/marks/takeRowOne.yml b/src/test/suite/fixtures/recorded/marks/takeRowOne.yml new file mode 100644 index 000000000..29b747cb0 --- /dev/null +++ b/src/test/suite/fixtures/recorded/marks/takeRowOne.yml @@ -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}}] diff --git a/src/test/suite/fixtures/recorded/lineNumbers/takeRowTwoPastDownThree.yml b/src/test/suite/fixtures/recorded/marks/takeRowTwoPastDownThree.yml similarity index 79% rename from src/test/suite/fixtures/recorded/lineNumbers/takeRowTwoPastDownThree.yml rename to src/test/suite/fixtures/recorded/marks/takeRowTwoPastDownThree.yml index c51da39c5..134bc7216 100644 --- a/src/test/suite/fixtures/recorded/lineNumbers/takeRowTwoPastDownThree.yml +++ b/src/test/suite/fixtures/recorded/marks/takeRowTwoPastDownThree.yml @@ -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}] diff --git a/src/test/suite/fixtures/recorded/lineNumbers/takeRowTwoPastFour.yml b/src/test/suite/fixtures/recorded/marks/takeRowTwoPastFour.yml similarity index 79% rename from src/test/suite/fixtures/recorded/lineNumbers/takeRowTwoPastFour.yml rename to src/test/suite/fixtures/recorded/marks/takeRowTwoPastFour.yml index ef3b2739c..4c1022739 100644 --- a/src/test/suite/fixtures/recorded/lineNumbers/takeRowTwoPastFour.yml +++ b/src/test/suite/fixtures/recorded/marks/takeRowTwoPastFour.yml @@ -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}] diff --git a/src/test/suite/fixtures/recorded/lineNumbers/takeUpOnePastDownOne.yml b/src/test/suite/fixtures/recorded/marks/takeUpOnePastDownOne.yml similarity index 79% rename from src/test/suite/fixtures/recorded/lineNumbers/takeUpOnePastDownOne.yml rename to src/test/suite/fixtures/recorded/marks/takeUpOnePastDownOne.yml index 64ed304d1..1b1598cf2 100644 --- a/src/test/suite/fixtures/recorded/lineNumbers/takeUpOnePastDownOne.yml +++ b/src/test/suite/fixtures/recorded/marks/takeUpOnePastDownOne.yml @@ -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}] diff --git a/src/test/suite/fixtures/recorded/lineNumbers/takeUpOnePastRowFour.yml b/src/test/suite/fixtures/recorded/marks/takeUpOnePastRowFour.yml similarity index 79% rename from src/test/suite/fixtures/recorded/lineNumbers/takeUpOnePastRowFour.yml rename to src/test/suite/fixtures/recorded/marks/takeUpOnePastRowFour.yml index 78cbc4e7d..69b0e7e2e 100644 --- a/src/test/suite/fixtures/recorded/lineNumbers/takeUpOnePastRowFour.yml +++ b/src/test/suite/fixtures/recorded/marks/takeUpOnePastRowFour.yml @@ -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}] diff --git a/src/typings/Types.ts b/src/typings/Types.ts index fa6cf760b..eee89d8bf 100644 --- a/src/typings/Types.ts +++ b/src/typings/Types.ts @@ -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 {