Skip to content

fix: leave key press callback handler for arrow keys

Seth Falco requested to merge SethFalco/gnome-calculator:fix/340 into master

Fixes a bug that caused trim whitespace to go off when moving the text cursor while holding CTRL.

The bug was caused from the behavior for superscript/subscript modes. Likely introduced in 8c7fa1d3. Before, whitespace was trimmed when a character was pressed in superscript or subscript mode. This was presumably to ensure exponents/logarithms were affixed to the number it applied to.

However, the user may be holding CTRL, not because they want superscript mode, but because they want to move the text cursor a word at a time.

This makes it so if we detect a left or right arrow key press, just leave the function early. No further processing is necessary. Trimming for superscript and subscript mode still works, since the user would be pressing a number rather than an arrow key.

Demo

The original behavior is demonstrated in the bug report, so omitted from this PR description.

Observe that when navigating with arrow keys, the whitespace is not trimmed.

Observe that when adding numbers in superscript mode, the whitespace is still trimmed.

Related

Edited by Seth Falco

Merge request reports