Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/components/composer/composer/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,7 @@ export class Composer extends Component<ComposerProps, SpreadsheetChildEnv> {
}
const newSelection = this.contentHelper.getCurrentSelection();

this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
this.props.onComposerContentFocused();
if (this.props.focus === "inactive") {
}
this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", newSelection);
this.processTokenAtCursor();
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/ui_stateful/edition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export class EditionPlugin extends UIPlugin {
case "CHANGE_COMPOSER_CURSOR_SELECTION":
this.selectionStart = cmd.start;
this.selectionEnd = cmd.end;
this.mode = "editing";
break;
case "STOP_COMPOSER_RANGE_SELECTION":
if (this.isSelectingForComposer()) {
Expand Down
1 change: 0 additions & 1 deletion tests/composer/autocomplete_dropdown_component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ describe("Autocomplete parenthesis", () => {
test("=S( + edit S with autocomplete does not add left parenthesis", async () => {
await typeInComposer("=S(");
// go behind the letter "S"
model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start: 2, end: 2 });
await nextTick();
// show autocomplete
Expand Down
13 changes: 9 additions & 4 deletions tests/composer/edition_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ describe("edition", () => {
expect(model.getters.getEditionMode()).toBe("inactive");
});

test("should switch to editing mode when composer cursor selection changes", () => {
const model = new Model();
model.dispatch("START_EDITION", { text: "=sum(" });
expect(model.getters.getEditionMode()).toBe("selecting");
model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start: 0, end: 5 });
expect(model.getters.getEditionMode()).toBe("editing");
});

test("Stopping the edition should complete the missing parenthesis of a formula", async () => {
const model = new Model();
model.dispatch("START_EDITION", { text: "=sum(sum(1,2" });
Expand Down Expand Up @@ -422,10 +430,7 @@ describe("edition", () => {
model.dispatch("START_EDITION");
model.dispatch("SET_CURRENT_CONTENT", {
content: "=",
});
model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", {
start: 1,
end: 1,
selection: { start: 1, end: 1 },
});

setSelection(model, ["A1:A3"]);
Expand Down