Skip to content

Fix#5321 field insertion over selected text in FormulaEditor - #7780

Open
leehaut wants to merge 1 commit into
apache:mainfrom
leehaut:hotfix/lance-common-110
Open

Fix#5321 field insertion over selected text in FormulaEditor#7780
leehaut wants to merge 1 commit into
apache:mainfrom
leehaut:hotfix/lance-common-110

Conversation

@leehaut

@leehaut leehaut commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fix #5321

Summary

  • Fix double-click field/function insertion in the expression editor so a selected range is replaced correctly regardless of selection direction (left-to-right vs right-to-left).
  • Replace the caret/substring/setText logic with StyledText.insert(), which handles selection replacement properly and avoids wiping undo history.
  • Apply the same fix to both User Defined Java Expression (janino) and Formula editor dialogs.

Root cause

The double-click handler treated getCaretPosition() as the start of the selection. When text is selected left-to-right, the caret is at the end of the selection, so the inserted field name was appended after the selection instead of replacing it.

Example:

  • Expression: isOk? 1: 0
  • Select 1 left → right, double-click field nameisOk? 1name: 0 (wrong)
  • Select 1 right → left, double-click field nameisOk? name: 0 (correct)

Signed-off-by: lance <leehaut@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: User defined Java expression - fields insertion on selected text

1 participant