diff --git a/packages/svelte2tsx/src/utils/htmlxparser.ts b/packages/svelte2tsx/src/utils/htmlxparser.ts index 7c5c35b97..a2682cfdd 100644 --- a/packages/svelte2tsx/src/utils/htmlxparser.ts +++ b/packages/svelte2tsx/src/utils/htmlxparser.ts @@ -163,7 +163,7 @@ function blankPossiblyErrorOperatorOrPropertyAccess(htmlx: string) { } htmlx = htmlx.substring(0, backwardIndex) + ' ' + htmlx.substring(backwardIndex + 1); - } else if (!/\s/.test(char)) { + } else if (!/\s/.test(char) && char !== ')' && char !== ']') { break; } backwardIndex--; diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/editing-bracket/expected.error.json b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-bracket/expected.error.json new file mode 100644 index 000000000..62c67b476 --- /dev/null +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-bracket/expected.error.json @@ -0,0 +1,16 @@ +{ + "name": "ParseError", + "code": "parse-error", + "start": { + "line": 1, + "column": 26, + "character": 26 + }, + "end": { + "line": 1, + "column": 26, + "character": 26 + }, + "pos": 26, + "frame": "1: {someRecord[anotherRecord.]}\n ^" +} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/editing-bracket/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-bracket/expectedv2.js new file mode 100644 index 000000000..3503b42fa --- /dev/null +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-bracket/expectedv2.js @@ -0,0 +1 @@ +someRecord[anotherRecord.]; \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/editing-bracket/input.svelte b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-bracket/input.svelte new file mode 100644 index 000000000..0b41edb28 --- /dev/null +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-bracket/input.svelte @@ -0,0 +1 @@ +{someRecord[anotherRecord.]} diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/editing-parentheses/expected.error.json b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-parentheses/expected.error.json new file mode 100644 index 000000000..ecd2606b1 --- /dev/null +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-parentheses/expected.error.json @@ -0,0 +1,16 @@ +{ + "name": "ParseError", + "code": "parse-error", + "start": { + "line": 1, + "column": 16, + "character": 16 + }, + "end": { + "line": 1, + "column": 16, + "character": 16 + }, + "pos": 16, + "frame": "1: {console.log(''.)}\n ^\n2: \n3: {#await Promise.resolve(''.)}" +} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/editing-parentheses/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-parentheses/expectedv2.js new file mode 100644 index 000000000..680bddbf2 --- /dev/null +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-parentheses/expectedv2.js @@ -0,0 +1,7 @@ +console.log(''.); + + { + +const $$_value = await (Promise.resolve(''.));{ const value = $$_value; + +}} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/editing-parentheses/input.svelte b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-parentheses/input.svelte new file mode 100644 index 000000000..e43762f0c --- /dev/null +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-parentheses/input.svelte @@ -0,0 +1,7 @@ +{console.log(''.)} + +{#await Promise.resolve(''.)} + +{:then value} + +{/await} \ No newline at end of file