Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b5d50c1
fix: respect line boundaries in text input shortcuts
Gautam-aman Oct 13, 2026
eace3a2
style: apply JabRef formatting to text input key bindings
Gautam-aman Oct 14, 2026
2b6e284
Fix shared line deletion and expand keyboard shortcut coverage
Gautam-aman Oct 18, 2026
a99ff54
Merge remote-tracking branch 'upstream/main' into fix/17256-line-shor…
github-actions[bot] Oct 19, 2026
9f72b35
Fix indentation in keyboard navigation test data
Gautam-aman Oct 19, 2026
0a731d8
Merge remote-tracking branch 'upstream/main' into fix/17256-line-shor…
github-actions[bot] Oct 19, 2026
6070237
Merge remote-tracking branch 'upstream/main' into fix/17256-line-shor…
github-actions[bot] Oct 20, 2026
d7368fc
Fix text input kill line undo and vertical caret movement
Gautam-aman Oct 21, 2026
dfcc29c
Merge remote-tracking branch 'origin/fix/17256-line-shortcuts' into f…
Gautam-aman Oct 21, 2026
3b33312
Merge remote-tracking branch 'upstream/main' into fix/17256-line-shor…
github-actions[bot] Oct 25, 2026
eaa98bb
Merge remote-tracking branch 'upstream/main' into fix/17256-line-shor…
github-actions[bot] Oct 28, 2026
309a240
fix: address line shortcut review feedback
Gautam-aman Oct 29, 2026
49d2b69
style: fix keyboard shortcut test formatting
Gautam-aman Oct 29, 2026
bc965a1
Merge remote-tracking branch 'upstream/main' into fix/17256-line-shor…
github-actions[bot] Oct 29, 2026
5de68d8
Merge remote-tracking branch 'upstream/main' into fix/17256-line-shor…
github-actions[bot] Oct 29, 2026
57c3414
Merge remote-tracking branch 'upstream/main' into fix/17256-line-shor…
github-actions[bot] Oct 30, 2026
e366622
Merge upstream/main into fix/17256-line-shortcuts
Gautam-aman Nov 1, 2026
0872621
fix: move caret across wrapped lines
Siedlerchr Nov 7, 2026
07eac8e
docs: trace visual line navigation
Siedlerchr Nov 7, 2026
f5948b9
test: cover vertical navigation boundaries
Siedlerchr Nov 7, 2026
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where icons kept a large size after lowering the font size until JabRef was restarted. [#17556](https://github.com/JabRef/jabref/issues/17556)
- We fixed an issue where the "Backup found" dialog appeared while another library's tab was selected. [#16919](https://github.com/JabRef/jabref/pull/16919)
- We fixed custom terminal and file browser commands failing when library directories contain spaces. [#12531](https://github.com/JabRef/jabref/issues/12531)
- We fixed line navigation and deletion shortcuts in multiline entry fields and the source editor. [#17256](https://github.com/JabRef/jabref/issues/17256)
- We fixed an issue where the "Get fulltext" button showed no progress during "Search full text documents online". [#17224](https://github.com/JabRef/jabref/pull/17224)

### Removed
Expand Down
17 changes: 17 additions & 0 deletions docs/requirements/ux.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@

Needs: impl

## Textual list filtering must be case-insensitive and separator-aware

Check failure on line 173 in docs/requirements/ux.md

View workflow job for this annotation

GitHub Actions / Spellling

TextLint [write-good]

"completely" is a weasel word | 173:50
`req~ux.text-filtering.case-insensitive-separators~1`

When users filter textual lists, matching must ignore case and treat punctuation or whitespace separators as equivalent.
For example, a search for `Springer lecture` or `SPRINGER LECTURE` or `springer lecture` should match `Springer - Lecture Notes in Computer Science`.

Needs: impl

Check failure on line 180 in docs/requirements/ux.md

View workflow job for this annotation

GitHub Actions / Spellling

TextLint [write-good]

"many" is a weasel word | 180:21
## Save before closing dialog must offer diff view of unsaved changes
`req~ux.close.show-diff~1`

Expand Down Expand Up @@ -238,6 +238,23 @@

Needs: impl

## Text editing shortcuts must respect line boundaries
`req~ux.text-editing.line-boundaries~2`

In multiline entry fields, beginning-of-line and end-of-line shortcuts move within the current newline-delimited line.
Document navigation shortcuts continue to move to the beginning or end of the whole field.
In entry fields and the source editor, kill-line removes text from the caret to the next newline, preserving subsequent lines.
At a line end, kill-line removes the newline and joins the following line; at the document end, it leaves the text unchanged.

Needs: impl, utest

## Vertical text navigation shortcuts must move across visible lines
`req~ux.text-editing.visual-line-navigation~1`

In multiline entry fields and the source editor, up and down shortcuts move the caret to the adjacent visible line, including within wrapped text.

Needs: impl, utest

## Donation prompt returns every six months
`req~ux.donation.recurring-prompt~1`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

public class CodeAreaKeyBindings {

// [impl->req~ux.text-editing.visual-line-navigation~1]
public static void call(CodeArea codeArea, KeyEvent event, KeyBindingRepository keyBindingRepository) {
handleMacCursorMovementShortcuts(codeArea, event);
if (event.isConsumed()) {
Expand Down Expand Up @@ -45,7 +46,7 @@ public static void call(CodeArea codeArea, KeyEvent event, KeyBindingRepository
event.consume();
}
case EDITOR_UP -> {
codeArea.moveParagraphStart();
codeArea.moveUp();
event.consume();
}
case EDITOR_BEGINNING -> {
Expand All @@ -57,7 +58,7 @@ public static void call(CodeArea codeArea, KeyEvent event, KeyBindingRepository
event.consume();
}
case EDITOR_DOWN -> {
codeArea.moveParagraphEnd();
codeArea.moveDown();
event.consume();
}
case EDITOR_END -> {
Expand Down Expand Up @@ -90,10 +91,14 @@ public static void call(CodeArea codeArea, KeyEvent event, KeyBindingRepository
event.consume();
}
case EDITOR_KILL_LINE -> {
int pos = textPosToOffset(codeArea, codeArea.getCaretPosition());
String text = codeArea.getText();
codeArea.setText(text.substring(0, pos));
codeArea.select(offsetToTextPos(codeArea, pos));
// [impl->req~ux.text-editing.line-boundaries~2]
TextPos caret = codeArea.getCaretPosition();
int lineEnd = codeArea.getPlainText(caret.index()).length();
TextPos end = TextPos.ofLeading(caret.index(), lineEnd);
if (caret.offset() == lineEnd && caret.index() + 1 < codeArea.getParagraphCount()) {
end = TextPos.ofLeading(caret.index() + 1, 0);
}
codeArea.replaceText(caret, end, "");
event.consume();
}
case EDITOR_KILL_WORD -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

import javafx.scene.Scene;
import javafx.scene.control.TextInputControl;
import javafx.scene.control.skin.TextAreaSkin;
import javafx.scene.control.skin.TextInputControlSkin.Direction;
import javafx.scene.control.skin.TextInputControlSkin.TextUnit;
import javafx.scene.input.KeyEvent;

import org.jabref.logic.util.strings.StringManipulator;
import org.jabref.model.util.ResultingStringState;

public class TextInputKeyBindings {

// [impl->req~ux.text-editing.line-boundaries~2]
// [impl->req~ux.text-editing.visual-line-navigation~1]
public static void call(Scene scene, KeyEvent event, KeyBindingRepository keyBindingRepository) {
if (scene.focusOwnerProperty().get() instanceof TextInputControl focusedTextField) {
keyBindingRepository.mapToKeyBinding(event).ifPresent(binding -> {
Expand All @@ -33,15 +38,32 @@ public static void call(Scene scene, KeyEvent event, KeyBindingRepository keyBin
focusedTextField.nextWord();
event.consume();
}
case EDITOR_BEGINNING,
EDITOR_UP,
EDITOR_BEGINNING_DOC -> {
case EDITOR_BEGINNING -> {
Comment thread
Gautam-aman marked this conversation as resolved.
Resolved
int caret = focusedTextField.getCaretPosition();
String text = focusedTextField.getText(0, focusedTextField.getLength());
focusedTextField.positionCaret(text.lastIndexOf('\n', caret - 1) + 1);
event.consume();
}
case EDITOR_END -> {
int caret = focusedTextField.getCaretPosition();
String text = focusedTextField.getText(0, focusedTextField.getLength());
int lineEnd = text.indexOf('\n', caret);
focusedTextField.positionCaret(lineEnd == -1 ? text.length() : lineEnd);
event.consume();
}
case EDITOR_UP -> {
Comment thread
Gautam-aman marked this conversation as resolved.
Resolved
moveCaretUp(focusedTextField);
event.consume();
}
case EDITOR_BEGINNING_DOC -> {
focusedTextField.home();
event.consume();
}
case EDITOR_END,
EDITOR_DOWN,
EDITOR_END_DOC -> {
case EDITOR_DOWN -> {
moveCaretDown(focusedTextField);
event.consume();
}
case EDITOR_END_DOC -> {
focusedTextField.end();
event.consume();
}
Expand Down Expand Up @@ -71,8 +93,14 @@ public static void call(Scene scene, KeyEvent event, KeyBindingRepository keyBin
}
case EDITOR_KILL_LINE -> {
Comment thread
Gautam-aman marked this conversation as resolved.
Resolved
int pos = focusedTextField.getCaretPosition();
focusedTextField.setText(focusedTextField.getText(0, pos));
focusedTextField.positionCaret(pos);
String text = focusedTextField.getText(0, focusedTextField.getLength());
int lineEnd = text.indexOf('\n', pos);
if (lineEnd == -1) {
lineEnd = text.length();
} else if (lineEnd == pos) {
lineEnd++;
}
focusedTextField.deleteText(pos, lineEnd);
event.consume();
}
case EDITOR_KILL_WORD -> {
Expand All @@ -96,4 +124,40 @@ public static void call(Scene scene, KeyEvent event, KeyBindingRepository keyBin
});
}
}

private static void moveCaretUp(TextInputControl control) {
Comment thread
Gautam-aman marked this conversation as resolved.
Resolved
if (control.getSkin() instanceof TextAreaSkin skin) {
skin.moveCaret(TextUnit.LINE, Direction.UP, false);
return;
}
int caret = control.getCaretPosition();
String text = control.getText(0, control.getLength());
int lineStart = text.lastIndexOf('\n', caret - 1) + 1;
if (lineStart == 0) {
control.positionCaret(0);
return;
}

int previousLineEnd = lineStart - 1;
int previousLineStart = text.lastIndexOf('\n', previousLineEnd - 1) + 1;
control.positionCaret(Math.min(previousLineStart + caret - lineStart, previousLineEnd));
}

private static void moveCaretDown(TextInputControl control) {
if (control.getSkin() instanceof TextAreaSkin skin) {
skin.moveCaret(TextUnit.LINE, Direction.DOWN, false);
return;
}
int caret = control.getCaretPosition();
String text = control.getText(0, control.getLength());
int lineStart = text.lastIndexOf('\n', caret - 1) + 1;
int lineEnd = text.indexOf('\n', caret);
if (lineEnd == -1) {
control.positionCaret(text.length());
return;
}

int nextLineEnd = text.indexOf('\n', lineEnd + 1);
control.positionCaret(Math.min(lineEnd + 1 + caret - lineStart, nextLineEnd == -1 ? text.length() : nextLineEnd));
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,145 @@
package org.jabref.gui.keyboard;

import java.util.Optional;
import java.util.stream.Stream;

import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.stage.Stage;

import org.jabref.gui.testutils.JavaFxExtension;

import jfx.incubator.scene.control.richtext.CodeArea;
import jfx.incubator.scene.control.richtext.LineEnding;
import jfx.incubator.scene.control.richtext.TextPos;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

@ExtendWith(JavaFxExtension.class)
class CodeAreaKeyBindingsTest {

@ParameterizedTest
@MethodSource("verticalNavigationBoundaryData")
// [utest->req~ux.text-editing.visual-line-navigation~1]
void verticalNavigationHandlesShortAndEmptyLines(KeyBinding binding, TextPos start, TextPos expected) {
JavaFxExtension.invokeAndWait(() -> {
CodeArea codeArea = new CodeArea();
codeArea.setText("abcdefghij\nx\n\nlastline");
Stage stage = new Stage();
stage.setScene(new Scene(codeArea, 400, 200));
stage.show();
codeArea.applyCss();
codeArea.layout();
codeArea.select(start);
codeArea.requestLayout();
codeArea.layout();
KeyBindingRepository repository = mock(KeyBindingRepository.class);
when(repository.mapToKeyBinding(any(KeyEvent.class))).thenReturn(Optional.of(binding));

CodeAreaKeyBindings.call(codeArea, new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.N, false, true, false, false), repository);

assertEquals(expected.index(), codeArea.getCaretPosition().index());
assertEquals(expected.offset(), codeArea.getCaretPosition().offset());
if (start.equals(expected)) {
codeArea.requestLayout();
codeArea.layout();
CodeAreaKeyBindings.call(codeArea, new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.N, false, true, false, false), repository);
assertEquals(expected.index(), codeArea.getCaretPosition().index());
assertEquals(expected.offset(), codeArea.getCaretPosition().offset());
}
});
}

private static Stream<Arguments> verticalNavigationBoundaryData() {
return Stream.of(
Arguments.of(KeyBinding.EDITOR_DOWN, TextPos.ofLeading(0, 8), TextPos.ofLeading(1, 1)),
Arguments.of(KeyBinding.EDITOR_DOWN, TextPos.ofLeading(1, 1), TextPos.ofLeading(2, 0)),
Arguments.of(KeyBinding.EDITOR_DOWN, TextPos.ofLeading(2, 0), TextPos.ofLeading(3, 0)),
Arguments.of(KeyBinding.EDITOR_UP, TextPos.ofLeading(2, 0), TextPos.ofLeading(1, 0)),
Arguments.of(KeyBinding.EDITOR_UP, TextPos.ZERO, TextPos.ZERO),
Arguments.of(KeyBinding.EDITOR_DOWN, TextPos.ofLeading(3, 8), TextPos.ofLeading(3, 8)));
}

@Test
// [utest->req~ux.text-editing.visual-line-navigation~1]
void verticalNavigationMovesAcrossWrappedVisualLines() {
JavaFxExtension.invokeAndWait(() -> {
CodeArea codeArea = new CodeArea();
codeArea.setWrapText(true);
codeArea.setText("A long paragraph that wraps over multiple visible lines without any newline characters. More words to ensure wrapping.");
Stage stage = new Stage();
stage.setScene(new Scene(codeArea, 150, 200));
stage.show();
codeArea.applyCss();
codeArea.layout();
codeArea.select(TextPos.ZERO);
KeyBindingRepository repository = mock(KeyBindingRepository.class);
when(repository.mapToKeyBinding(any(KeyEvent.class))).thenReturn(Optional.of(KeyBinding.EDITOR_DOWN), Optional.of(KeyBinding.EDITOR_UP));

CodeAreaKeyBindings.call(codeArea, new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.N, false, true, false, false), repository);
int nextLine = codeArea.getCaretPosition().offset();
assertTrue(nextLine > 0 && nextLine < codeArea.getText().length());
codeArea.requestLayout();
codeArea.layout();

CodeAreaKeyBindings.call(codeArea, new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.P, false, true, false, false), repository);
assertEquals(TextPos.ZERO, codeArea.getCaretPosition());
});
}

@ParameterizedTest
@MethodSource("killLineTestData")
// [utest->req~ux.text-editing.line-boundaries~2]
void killLinePreservesFollowingLines(LineEnding lineEnding, String text, TextPos caretPosition, String expectedText) {
JavaFxExtension.invokeAndWait(() -> {
CodeArea codeArea = new CodeArea();
new Scene(codeArea);
codeArea.applyCss();
codeArea.getModel().setLineEnding(lineEnding);
codeArea.setText(text);
codeArea.select(caretPosition);
KeyBindingRepository repository = mock(KeyBindingRepository.class);
when(repository.mapToKeyBinding(any(KeyEvent.class))).thenReturn(Optional.of(KeyBinding.EDITOR_KILL_LINE));
KeyEvent event = new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.K, false, true, false, false);

CodeAreaKeyBindings.call(codeArea, event, repository);

assertEquals(expectedText.replace("\n", lineEnding.getText()), codeArea.getText());
assertEquals(caretPosition, codeArea.getCaretPosition());
assertTrue(event.isConsumed());
codeArea.undo();
assertEquals(text, codeArea.getText());
});
}

private static Stream<Arguments> killLineTestData() {
return Stream.of(LineEnding.LF, LineEnding.CRLF).flatMap(lineEnding -> {
String separator = lineEnding.getText();
return Stream.of(
Arguments.of(lineEnding, "First" + separator + "Second" + separator + "Third", TextPos.ofLeading(0, 3), "Fir\nSecond\nThird"),
Arguments.of(lineEnding, "First" + separator + "Second" + separator + "Third", TextPos.ofLeading(0, 5), "FirstSecond\nThird"),
Arguments.of(lineEnding, "First" + separator + "Second" + separator + "Third", TextPos.ofLeading(1, 0), "First\n\nThird"),
Arguments.of(lineEnding, "First" + separator + "Second" + separator + "Third", TextPos.ofLeading(1, 3), "First\nSec\nThird"),
Arguments.of(lineEnding, "First" + separator + "Second" + separator + "Third", TextPos.ofLeading(2, 5), "First\nSecond\nThird"),
Arguments.of(lineEnding, "First" + separator, TextPos.ofLeading(0, 5), "First"),
Arguments.of(lineEnding, "First" + separator, TextPos.ofLeading(1, 0), "First\n"),
Arguments.of(lineEnding, "", TextPos.ZERO, ""));
});
}

@Test
void nonMacOsDoesNothing() {
CodeArea codeArea = mock(CodeArea.class);
Expand Down
Loading
Loading