diff --git a/src/helpers/pivot/pivot_composer_helpers.ts b/src/helpers/pivot/pivot_composer_helpers.ts index 849f9480b1..c313a56598 100644 --- a/src/helpers/pivot/pivot_composer_helpers.ts +++ b/src/helpers/pivot/pivot_composer_helpers.ts @@ -1,6 +1,6 @@ import { tokenColors } from "../../components/composer/composer/composer"; import { ComposerStore } from "../../components/composer/composer/composer_store"; -import { Token, getFunctionsFromTokens } from "../../formulas"; +import { getFunctionsFromTokens, Token } from "../../formulas"; import { EnrichedToken } from "../../formulas/composer_tokenizer"; import { Granularity, PivotField } from "../../types"; @@ -41,6 +41,7 @@ export function insertTokenAfterArgSeparator( // replace the whole token start = tokenAtCursor.start; } + this.composer.stopComposerRangeSelection(); this.composer.changeComposerCursorSelection(start, end); this.composer.replaceComposerCursorSelection(value); } @@ -63,6 +64,7 @@ export function insertTokenAfterLeftParenthesis( // replace the whole token start = tokenAtCursor.start; } + this.composer.stopComposerRangeSelection(); this.composer.changeComposerCursorSelection(start, end); this.composer.replaceComposerCursorSelection(value); } diff --git a/tests/composer/auto_complete/pivot_auto_complete_store.test.ts b/tests/composer/auto_complete/pivot_auto_complete_store.test.ts index 8fbb433819..3a0a2cdde7 100644 --- a/tests/composer/auto_complete/pivot_auto_complete_store.test.ts +++ b/tests/composer/auto_complete/pivot_auto_complete_store.test.ts @@ -19,6 +19,8 @@ describe("spreadsheet pivot auto complete", () => { ); for (const func of ["PIVOT", "PIVOT.HEADER", "PIVOT.VALUE"]) { composer.startEdition(`=${func}(`); + expect(composer.isSelectingRange).toBeTruthy(); + const autoComplete = composer.autocompleteProvider; expect(autoComplete?.proposals).toEqual([ { @@ -36,6 +38,8 @@ describe("spreadsheet pivot auto complete", () => { ]); autoComplete?.selectProposal(autoComplete?.proposals[0].text); expect(composer.currentContent).toBe(`=${func}(1`); + // range selection stops + expect(composer.isSelectingRange).toBeFalsy(); expect(composer.autocompleteProvider).toBeUndefined(); composer.cancelEdition(); } @@ -62,7 +66,7 @@ describe("spreadsheet pivot auto complete", () => { } }); - test("PIVOT.VALUE measuresgd", async () => { + test("PIVOT.VALUE measures", async () => { const model = createModelWithPivot("A1:I5"); updatePivot(model, "1", { columns: [],