From 963675e7bd7658715a206548ad409e39ac411826 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 30 Nov 2023 13:53:23 +0100 Subject: [PATCH] Add padding --- .../fixtures/scopes/plaintext/character.scope | 2 ++ .../suite/fixtures/scopes/plaintext/line2.scope | 2 ++ .../suite/fixtures/scopes/plaintext/word.scope | 1 + .../suite/fixtures/scopes/plaintext/word2.scope | 1 + .../src/suite/serializeScopes.ts | 16 ++++++++-------- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/character.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/character.scope index 413a0f25a1..92ce8be6f4 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/character.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/character.scope @@ -9,6 +9,7 @@ aaa [#1 Insertion delimiter] = "" + [#2 Content] = [#2 Removal] = [#2 Domain] = 0:1-0:2 @@ -17,6 +18,7 @@ aaa [#2 Insertion delimiter] = "" + [#3 Content] = [#3 Removal] = [#3 Domain] = 0:2-0:3 diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/line2.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/line2.scope index 0305d7c868..aa70ecc82b 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/line2.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/line2.scope @@ -30,6 +30,7 @@ aaa [#1 Insertion delimiter] = "\n" + [#2 Content] = [#2 Domain] = 1:0-1:3 0| @@ -65,6 +66,7 @@ aaa [#2 Insertion delimiter] = "\n" + [#3 Content] = [#3 Domain] = 2:0-2:0 0| diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/word.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/word.scope index 6af9658dda..c8b08df664 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/word.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/word.scope @@ -16,6 +16,7 @@ aaa_bbb [#1 Insertion delimiter] = "_" + [#2 Content] = [#2 Domain] = 0:4-0:7 0| aaa_bbb diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/word2.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/word2.scope index dbc83e4658..a94f3eb776 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/word2.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/plaintext/word2.scope @@ -9,6 +9,7 @@ aaaBbb [#1 Insertion delimiter] = "" + [#2 Content] = [#2 Removal] = [#2 Domain] = 0:3-0:6 diff --git a/packages/cursorless-vscode-e2e/src/suite/serializeScopes.ts b/packages/cursorless-vscode-e2e/src/suite/serializeScopes.ts index 33bba62081..c138ed6e1e 100644 --- a/packages/cursorless-vscode-e2e/src/suite/serializeScopes.ts +++ b/packages/cursorless-vscode-e2e/src/suite/serializeScopes.ts @@ -1,19 +1,19 @@ import { Range, ScopeRanges, TargetRanges } from "@cursorless/common"; export function serializeScopes(code: string, scopes: ScopeRanges[]): string { - const codeLines = code.split("\n"); - return [ - ...codeLines, - "---", - ...scopes.map((scope, index) => + const codeLines = code.split(/\r?\n/g); + + const serializedScopes = scopes + .map((scope, index) => serializeScope( codeLines, scope, scopes.length > 1 ? index + 1 : undefined, ), - ), - "", - ].join("\n"); + ) + .join("\n\n"); + + return [...codeLines, "---", serializedScopes, ""].join("\n"); } function serializeScope(