Skip to content

Commit

Permalink
fix: find the first possible cursor position
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Oct 31, 2024
1 parent b21a430 commit f4b020f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/docs-ui/src/commands/commands/ime-input.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const IMEInputCommand: ICommand<IIMEInputCommandParams> = {
}

const previousActiveRange = imeInputManagerService.getActiveRange();
if (!previousActiveRange) {
if (previousActiveRange == null) {
return false;
}

Expand All @@ -66,7 +66,7 @@ export const IMEInputCommand: ICommand<IIMEInputCommandParams> = {

const insertRange = BuildTextUtils.selection.getInsertSelection(previousActiveRange, body);
Object.assign(previousActiveRange, insertRange);
const { startOffset } = previousActiveRange;
const { startOffset, endOffset } = previousActiveRange;

const len = newText.length;

Expand All @@ -90,7 +90,12 @@ export const IMEInputCommand: ICommand<IIMEInputCommandParams> = {

const defaultTextStyle = docMenuStyleService.getDefaultStyle();
const styleCache = docMenuStyleService.getStyleCache();
const curTextRun = getTextRunAtPosition(body.textRuns ?? [], startOffset + oldTextLen, defaultTextStyle, styleCache);
const curTextRun = getTextRunAtPosition(
body.textRuns ?? [],
isCompositionStart ? endOffset : startOffset + oldTextLen,
defaultTextStyle,
styleCache
);

const textX = new TextX();
const jsonX = JSONX.getInstance();
Expand Down

0 comments on commit f4b020f

Please sign in to comment.