Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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 @@ -87,6 +87,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where "Automatically set file links" did not work when no external file types were configured. [#15084](https://github.com/JabRef/jabref/issues/15084)
- We fixed an issue where citing organisations in JStyle format was not sorting or displaying properly in LibreOffice. [#11725](https://github.com/JabRef/jabref/issues/11725)
- We fixed an issue where "Perform OCR" button remained enabled for broken or missing linked files. [#16736](https://github.com/JabRef/jabref/issues/16736)
- We fixed line navigation and deletion shortcuts in multiline entry fields and the source editor. [#17256](https://github.com/JabRef/jabref/issues/17256)

### Removed

Expand Down
8 changes: 8 additions & 0 deletions docs/requirements/ux.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@
`req~ux.external-library-changes.after-save~1`

When JabRef saves a library, it must keep observing filesystem changes, defer change detection until the save has finished, and then inspect the resulting file for external changes that require conflict resolution.
Since inspecting a library file means parsing it completely, the inspection is skipped when the file's size and modification time show that it has not changed since the last state known to match the in-memory library.

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

View workflow job for this annotation

GitHub Actions / Spellling

TextLint [write-good]

"completely" is a weasel word | 145:50

Needs: impl

## Bulk entry deletion must keep main table responsive
`req~ux.large-library.bulk-entry-removal~1`

When a user deletes many entries from a large library, JabRef must keep the main table responsive.

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

View workflow job for this annotation

GitHub Actions / Spellling

TextLint [write-good]

"many" is a weasel word | 152:21

Needs: impl

Expand Down Expand Up @@ -228,4 +228,12 @@

Needs: impl

## Text editing shortcuts respect line boundaries
Comment thread
Gautam-aman marked this conversation as resolved.
Resolved
`req~ux.text-editing.line-boundaries~1`

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.

<!-- markdownlint-disable-file MD022 -->
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ public static void call(CodeArea codeArea, KeyEvent event, KeyBindingRepository
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));
ResultingStringState res = StringManipulator.killLine(pos, text);
codeArea.setText(res.text);
codeArea.select(offsetToTextPos(codeArea, res.caretPosition));
Comment thread
Gautam-aman marked this conversation as resolved.
Resolved
event.consume();
}
case EDITOR_KILL_WORD -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.keyboard;

import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextInputControl;
import javafx.scene.input.KeyEvent;

Expand Down Expand Up @@ -33,15 +34,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 +89,9 @@ 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());
ResultingStringState res = StringManipulator.killLine(pos, text);
focusedTextField.deleteText(pos, pos + text.length() - res.text.length());
Comment thread
Gautam-aman marked this conversation as resolved.
Resolved
event.consume();
}
case EDITOR_KILL_WORD -> {
Expand All @@ -96,4 +115,42 @@ 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 instanceof TextArea)) {
control.home();
return;
}

int caret = control.getCaretPosition();
String text = control.getText();
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 instanceof TextArea)) {
control.end();
return;
}

int caret = control.getCaretPosition();
String text = control.getText();
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,58 @@
package org.jabref.gui.keyboard;

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

import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;

import org.jabref.gui.testutils.JavaFxExtension;

import jfx.incubator.scene.control.richtext.CodeArea;
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("killLineTestData")
void killLinePreservesFollowingLines(TextPos caretPosition, String expectedText) {
CodeArea codeArea = new CodeArea();
codeArea.setText("First\nSecond\nThird");
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, codeArea.getText());
assertEquals(caretPosition, codeArea.getCaretPosition());
assertTrue(event.isConsumed());
}

private static Stream<Arguments> killLineTestData() {
return Stream.of(
Arguments.of(TextPos.ofLeading(0, 3), "Fir\nSecond\nThird"),
Arguments.of(TextPos.ofLeading(0, 5), "FirstSecond\nThird"),
Arguments.of(TextPos.ofLeading(1, 0), "First\n\nThird"),
Arguments.of(TextPos.ofLeading(2, 5), "First\nSecond\nThird"));
}

@Test
void nonMacOsDoesNothing() {
CodeArea codeArea = mock(CodeArea.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package org.jabref.gui.keyboard;

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

import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.TextInputControl;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;

import org.jabref.gui.testutils.JavaFxExtension;

import org.jspecify.annotations.NullMarked;
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.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@NullMarked
@ExtendWith(JavaFxExtension.class)
class TextInputKeyBindingsTest {
Comment thread
Gautam-aman marked this conversation as resolved.
Resolved

private static final String MULTILINE_TEXT = "First line\nSecond line\nThird line";

private void applyBinding(TextInputControl control, KeyBinding binding) {
Scene scene = mock(Scene.class);
KeyBindingRepository repository = mock(KeyBindingRepository.class);

ReadOnlyObjectWrapper<Node> focusOwner = new ReadOnlyObjectWrapper<>(control);

when(scene.focusOwnerProperty())
.thenReturn(focusOwner.getReadOnlyProperty());

when(repository.mapToKeyBinding(any(KeyEvent.class)))
.thenReturn(Optional.of(binding));

KeyEvent event = new KeyEvent(
KeyEvent.KEY_PRESSED,
"",
"",
KeyCode.A,
false,
true,
false,
false);

TextInputKeyBindings.call(scene, event, repository);

assertTrue(event.isConsumed());
}

@Test
void killLineUsesSharedLineDeletion() {
TextArea area = new TextArea(MULTILINE_TEXT);
area.positionCaret(16);

applyBinding(area, KeyBinding.EDITOR_KILL_LINE);

assertEquals("First line\nSecon\nThird line", area.getText());
assertEquals(16, area.getCaretPosition());
}

@Test
void killLineCanBeUndoneInTextField() {
TextField field = new TextField("search query");
field.positionCaret(7);

applyBinding(field, KeyBinding.EDITOR_KILL_LINE);

assertEquals("search ", field.getText());
assertEquals(7, field.getCaretPosition());
field.undo();
assertEquals("search query", field.getText());
}

@ParameterizedTest
@MethodSource("navigationTestData")
void navigationRespectsLineAndDocumentBoundaries(boolean multiline, String text, int caretPosition, KeyBinding binding, int expectedPosition) {
TextInputControl control = multiline ? new TextArea(text) : new TextField(text);
control.positionCaret(caretPosition);

applyBinding(control, binding);

assertEquals(expectedPosition, control.getCaretPosition());
assertEquals(text, control.getText());
}

private static Stream<Arguments> navigationTestData() {
Comment thread
Gautam-aman marked this conversation as resolved.
Resolved
return Stream.concat(Stream.of(true, false).flatMap(multiline -> Stream.of(
Arguments.of(multiline, "", 0, KeyBinding.EDITOR_BEGINNING, 0),
Arguments.of(multiline, "", 0, KeyBinding.EDITOR_END, 0),
Arguments.of(multiline, "", 0, KeyBinding.EDITOR_BEGINNING_DOC, 0),
Arguments.of(multiline, "", 0, KeyBinding.EDITOR_END_DOC, 0),
Arguments.of(multiline, "Example text", 7, KeyBinding.EDITOR_BEGINNING, 0),
Arguments.of(multiline, "Example text", 3, KeyBinding.EDITOR_END, 12))),
Stream.of(
Arguments.of(true, MULTILINE_TEXT, 5, KeyBinding.EDITOR_BEGINNING, 0),
Arguments.of(true, MULTILINE_TEXT, 5, KeyBinding.EDITOR_END, 10),
Arguments.of(true, MULTILINE_TEXT, 10, KeyBinding.EDITOR_BEGINNING, 0),
Arguments.of(true, MULTILINE_TEXT, 10, KeyBinding.EDITOR_END, 10),
Arguments.of(true, MULTILINE_TEXT, 11, KeyBinding.EDITOR_BEGINNING, 11),
Arguments.of(true, MULTILINE_TEXT, 11, KeyBinding.EDITOR_END, 22),
Arguments.of(true, MULTILINE_TEXT, 16, KeyBinding.EDITOR_BEGINNING, 11),
Arguments.of(true, MULTILINE_TEXT, 16, KeyBinding.EDITOR_END, 22),
Arguments.of(true, MULTILINE_TEXT, 16, KeyBinding.EDITOR_BEGINNING_DOC, 0),
Arguments.of(true, MULTILINE_TEXT, 16, KeyBinding.EDITOR_END_DOC, 33),
Arguments.of(true, MULTILINE_TEXT, 28, KeyBinding.EDITOR_UP, 16),
Arguments.of(true, MULTILINE_TEXT, 5, KeyBinding.EDITOR_UP, 0),
Arguments.of(true, MULTILINE_TEXT, 5, KeyBinding.EDITOR_DOWN, 16),
Arguments.of(true, MULTILINE_TEXT, 20, KeyBinding.EDITOR_DOWN, 32),
Arguments.of(true, MULTILINE_TEXT, 28, KeyBinding.EDITOR_DOWN, 33),
Arguments.of(true, "Long line\nx", 6, KeyBinding.EDITOR_DOWN, 11),
Arguments.of(true, MULTILINE_TEXT, 28, KeyBinding.EDITOR_BEGINNING, 23),
Arguments.of(true, MULTILINE_TEXT, 28, KeyBinding.EDITOR_END, 33),
Arguments.of(true, "First\n", 6, KeyBinding.EDITOR_BEGINNING, 6),
Arguments.of(true, "First\n", 6, KeyBinding.EDITOR_END, 6)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ public static ResultingStringState lowercase(int caretPosition, String text) {
return setWordCase(text, caretPosition, LetterCase.LOWER);
}

public static ResultingStringState killLine(int caretPosition, String text) {
Comment thread
Gautam-aman marked this conversation as resolved.
Resolved
int lineEnd = text.indexOf('\n', caretPosition);
if (lineEnd == -1) {
lineEnd = text.length();
} else if (lineEnd == caretPosition) {
lineEnd++;
}
return new ResultingStringState(caretPosition, text.substring(0, caretPosition) + text.substring(lineEnd));
}

/// Remove the next word on the right side of the cursor.
///
/// @param caretPosition The position of the cursor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,32 @@

class StringManipulatorTest {

@ParameterizedTest
@MethodSource("killLineTestData")
void killLinePreservesFollowingLines(String text, int caretPosition, String expectedText) {
ResultingStringState result = StringManipulator.killLine(caretPosition, text);

assertEquals(expectedText, result.text);
assertEquals(caretPosition, result.caretPosition);
}

private static Stream<Arguments> killLineTestData() {
return Stream.of(
Arguments.of("", 0, ""),
Arguments.of("Example text", 0, ""),
Arguments.of("Example text", 7, "Example"),
Arguments.of("Example text", 12, "Example text"),
Arguments.of("First\nSecond\nThird", 2, "Fi\nSecond\nThird"),
Arguments.of("First\nSecond\nThird", 5, "FirstSecond\nThird"),
Arguments.of("First\nSecond\nThird", 6, "First\n\nThird"),
Arguments.of("First\nSecond\nThird", 9, "First\nSec\nThird"),
Arguments.of("First\nSecond\nThird", 15, "First\nSecond\nTh"),
Arguments.of("First\nSecond\nThird", 18, "First\nSecond\nThird"),
Arguments.of("First\n\nThird", 6, "First\nThird"),
Arguments.of("First\n", 5, "First"),
Arguments.of("First\n", 6, "First\n"));
}

@Test
void capitalizePreservesNewlines() {
int caretPosition = 5; // Position of the caret, between the two ll in the first hellO"
Expand Down
Loading