Repository navigation
fix: respect line boundaries in text input shortcuts - #17460
Conversation
|
@Gautam-aman , hi! Could you please specify how to do this: "Configure beginning-of-line, end-of-line, and kill-line shortcuts as Control+A, Control+E, and Control+K, respectively." It's not configured in JabRef by default? |
|
hey! You're right, they're not set by default. You can assign them manually under File → Preferences → Keyboard shortcuts. |
|
Ok, good! All shortcuts work (except the Ctrl-A, for some reason I couldn't test it because there was not possible to edit the action for it, there was no "Move to the beginning of the line"). Now rests the code review, which I will do later UPD: I was able to test the beginning of the line, all good |
|
Great, thanks for testing and confirming! Glad everything's working. Looking forward to your feedback on the code review. |
LoayTarek5
left a comment
There was a problem hiding this comment.
ok @Gautam-aman, great work, also please add a CHANGELOG entry, remove the extra blank lines, and fill the checklist.
could you also please add like screenshots, or video to demonstrate
|
Thanks for the review! I’ve addressed the code and test feedback, added the changelog entry, and pushed the formatting fix. |
|
Overall looks good but I found some issues while testing: New regression: Kill line replaces the entire text value. In the global search field, Cmd + K deleted the rest of the line, but Cmd + Z could not restore it. Undo worked for ordinary typing in the same field. A range deletion would preserve the text control’s editing behavior; JavaFX distinguishes deleteText from setText. https://openjfx.io/javadoc/27/javafx.controls/javafx/scene/control/TextInputControl.html Pre-existing issue: Move caret up/down calls home()/end(). In a multiline abstract, Cmd + P jumped from the last line to the start of the document. |
Code Review by QodoResolved findings 1.
|
|
The up/down shortcuts skip wrapped visual lines in multiline fields. For example, with a long Abstract paragraph, I would say, this is a follow up task |
|
I now fixed the up/down behavior and also in the code area, otherwise it was already good! |
|
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin port-17460-to-black-forest
git worktree add --checkout .worktree/port-17460-to-black-forest port-17460-to-black-forest
cd .worktree/port-17460-to-black-forest
git reset --hard HEAD^
git cherry-pick -x c88bfa998a90ac3d728068594ced605d33e55e32 |
|
Hey @Siedlerchr, thanks for merging the PR! I noticed the backport to |
Summary
Fixes beginning-of-line, end-of-line, and kill-line keyboard shortcuts in multiline text fields such as Abstract and Comment.
Previously, line-navigation shortcuts behaved like document-navigation shortcuts, while kill-line removed all text after the caret, including subsequent lines.
This change separates line and document navigation, restricts line editing to newline-delimited boundaries, and preserves existing single-line text field behavior.
Analogies: Like navigating within a single paragraph instead of jumping to the beginning or end of an entire document, this change keeps text-editing shortcuts focused on the current line.
Steps to test
Screenshot of the shortcut result: pending.
Core-library checks, focused keyboard-binding tests, Checkstyle, Modernizer, OpenRewrite, Javadoc, Markdown lint, and textlint passed locally.
Related issues and pull requests
Closes #17256
Related: #17415 (previously closed without merging).
AI usage
ChatGPT assisted with tests, debugging, and the initial PR text.
AI CHECKLIST.md walkthrough
Code checklist
1. Code self-review
Read your own diff once, top to bottom, and confirm each point.
Nullability and control flow
== null/!= nullchecks — JSpecify annotations (@NullMarked,@Nullable,@NonNull) used instead.Objects.requireNonNull(...)— nullability expressed via JSpecify annotations.@NullMarked(org.jspecify.annotations.NullMarked).@NullMarked(org.jspecify.annotations.NullMarked).Optionalconsumed withifPresent/ifPresentOrElse/map/orElseThrow— neverorElse(unusedValue)nor anisPresent()+get()block.StringUtil.isBlank(...)used instead ofs == null || s.isBlank().Exceptions
catch (Exception e)— only specific exceptions are caught.throw new RuntimeException(...)/IllegalStateException(...)— these tear down the whole application.LOGGER.info("...", e)), not concatenated into the message string.Style and idioms
BibEntryobjects built with withers (withField, notsetField).List.of()/Map.of()/Set.of(),Path.of(),SequencedCollection/SequencedSet, text blocks.Pattern.compile(...)constant, notString.matches(...).org.jabref.logic.util.BackgroundTask, notnew Thread().///) uses Markdown syntax, not JavaDoc inline tags:`code`instead of{@code},[ClassName]instead of{@link}.User-facing text
Localization.langin Java,%prefix in FXML).!; labels do not end with:."...: %0"), not string concatenation.Security
text/htmlresponse — including exception/error messages, not just the success body (XSS).Tests
org.jabref.model/org.jabref.logichave added or updated tests.assertEquals), use plain JUnit asserts (not AssertJ), have no@DisplayName, do not catch exceptions (let them propagate so JUnit reports setup/teardown failures directly), and use@TempDirinstead of manual temp directories.2. Verification commands
Run in this order — cheapest first. Each must pass.
./gradlew :jablib:check(or./gradlew checkfor all modules)../gradlew checkstyleMain checkstyleTest checkstyleJmh../gradlew modernizer../gradlew --no-configuration-cache :rewriteDryRunreports no changes (run./gradlew rewriteRunto fix)../gradlew javadoc.npx markdownlint-cli2 "docs/**/*.md" "*.md"(only if Markdown changed).npm ci && npm run textlintreports no misspellings (only if Markdown changed).rewriteRun:docker run -v $(pwd):/github/workspace ghcr.io/leventebajczi/intellij-format:master "*.java" "" ".idea/codeStyles/Project.xml".3. Documentation
CHANGELOG.mdentry added if the change is visible to the user (end-user wording, no extra blank lines, sorted in next to existing entries about the same component/feature). Link the issue if one exists; link the PR only when no issue exists. UseTODOas the placeholder when neither is known yet — never a fake number. No entry for fixes to changes that were themselves introduced after the last release (feature only in## [Unreleased]) — update the existing unreleased entry instead if needed.TODO(nocloses/fixesfor merely-similar issues).docs/requirements/<area>.mdif the change is a new feature or significant bug fix (skip for refactors, minor fixes, and internal changes).docs/updated if behavior or architecture changed.4. Pull request
.github/PULL_REQUEST_TEMPLATE.md, every section filled.[x],[ ], or[/].gh pr create --body-file <file>(not--body).CHANGELOG.mdused aTODOplaceholder (no issue confidently identified yet — an existing issue link always stays), the PR was opened as draft, the placeholder was replaced with the real PR-number link after PR creation, committed and pushed, and only then was the PR marked ready for review. If an issue is identified or created later, the link is switched to the issue.Checklist
CHANGELOG.mdlinked to the issue.Screenshot
Before — Incorrect line shortcut behavior
After — Fixed line shortcut behavior
Beginning/end-of-line shortcuts now respect the current line boundaries. Kill-line removes only the remaining text on the current line, preserving subsequent lines.