Skip to content

Feat: Add Option to Delete Whole Words When Holding Backspace#2329

Open
defleur-agents wants to merge 1 commit intoHeliBorg:mainfrom
humanitylabs-org:feature/hold-backspace-delete-word-upstream
Open

Feat: Add Option to Delete Whole Words When Holding Backspace#2329
defleur-agents wants to merge 1 commit intoHeliBorg:mainfrom
humanitylabs-org:feature/hold-backspace-delete-word-upstream

Conversation

@defleur-agents
Copy link

Adds a "Hold backspace deletes whole words" toggle in Text Correction settings (off by default). When enabled, holding the backspace key deletes entire words instead of individual characters.

Related: #1289 — this addresses the hold-backspace behavior discussed in that thread. The swipe-delete behavior requested in the original issue is not changed by this PR.

Implementation

  • Uses BreakIterator.getWordInstance() for accurate word boundary detection
  • Gradually increasing repeat speed (starts slow, speeds up with continued holding)
  • Haptic feedback fires on every word deletion
  • Composing words are deleted whole on the first repeat
  • All behavior changes are behind the settings toggle — default behavior is unchanged

Files Changed

  • InputLogic.java — word deletion logic for both composing and committed text
  • PointerTracker.java — adjusted repeat timing when deleting words
  • LatinIME.java — haptic feedback on every backspace repeat when enabled
  • Settings.java / Defaults.kt / SettingsValues.java — new preference
  • TextCorrectionScreen.kt — settings UI
  • strings.xml — setting label and description

Adds a new setting 'Hold backspace deletes whole words' under Text correction
(off by default). When enabled:

- Holding backspace deletes entire words instead of individual characters
- Uses BreakIterator.getWordInstance() for accurate word boundary detection
- Gradually increasing repeat speed with haptic feedback on each deletion
- Composing words are deleted whole on first repeat
- Works in both standard and TYPE_NULL input fields

Default behavior is unchanged for users who don't enable the setting.
Copy link
Contributor

@eranl eranl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this deal with punctuation and other non-word characters?

if (textBeforeCursor != null && textBeforeCursor.length() > 0) {
final java.text.BreakIterator breakIterator;
if (deleteWholeWords) {
breakIterator = java.text.BreakIterator.getWordInstance();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses the default locale. It also uses some built-in word-breaking logic, which differs between Android versions. And it ignores HeliBoard's word separators.

if (autocorrectEnabled) Settings.PREF_AUTOCORRECT_SHORTCUTS else null,
if (autocorrectEnabled) Settings.PREF_AUTO_CORRECT_THRESHOLD else null,
if (autocorrectEnabled) Settings.PREF_BACKSPACE_REVERTS_AUTOCORRECT else null,
Settings.PREF_DELETE_WHOLE_WORDS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this setting belongs on the Preferences or Advanced screens.

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.

2 participants