[ZEPPELIN-6710] Keep Enter as a newline for no-op Monaco suggestions - #5490
Merged
voidmatcha merged 1 commit intoSep 20, 2026
Merged
Conversation
When word-based suggestions offer a candidate identical to the word just
typed, accepting it is a no-op. With acceptSuggestionOnEnter at its
default ('on'), Enter accepted that no-op suggestion and the newline was
swallowed, so rapid multi-line typing silently dropped line breaks.
Set acceptSuggestionOnEnter to 'smart' so Enter falls through as a
newline when the focused suggestion would not change the text.
Interpreter completion (Ctrl+Space, a manual trigger) and inline
ghost-text are a separate path and are unaffected.
Add an e2e regression covering the auto-suggest Enter path.
jongyoul
approved these changes
Sep 20, 2026
ParkGyeongTae
approved these changes
Sep 20, 2026
ParkGyeongTae
left a comment
Member
There was a problem hiding this comment.
LGTM. The change is focused, and the new E2E test passes locally.
Member
|
Merged into master (7076ea4). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR for?
In the New UI paragraph editor (Monaco), pressing Enter can be silently swallowed while the auto-suggest popup is open, dropping a line break so the next characters land on the current line instead of a new one.
The trigger is a no-op suggestion. When word-based suggestions offer a candidate identical to the word the user just finished typing, accepting it changes nothing. With Monaco's
acceptSuggestionOnEnterleft at its default ('on'), Enter accepts that no-op candidate instead of inserting a newline: the keystroke is consumed, the line break never lands, and rapid multi-line typing loses lines.The fix sets
acceptSuggestionOnEnter: 'smart'on the paragraph editor. The auto-suggest popup still appears; only the Enter behavior changes, and only for a focused candidate whose acceptance would not change the text.Why
'smart'over the alternativeswordBasedSuggestions: 'off'— removes the document-word completion feature entirely. That is heavier than the bug warrants, and it is not even the right lever: Monaco's built-in word-based provider already filters out an exact match of the current token (editorSimpleWorker.js,if (word === leadingWord) continue), so turning it off does not target the actual no-op source.completion.service.ts) — the most surgical removal of the candidate, but it changes interpreter completion behavior, which ZEPPELIN-6710 explicitly lists as out of scope ("Changing interpreter completion behavior or the Ctrl+Space-then-Enter accept flow"). It also lives outsideupdateEditorOptions(), which the issue scopes the change to.acceptSuggestionOnEnter: 'smart'— a one-line change insideupdateEditorOptions(), keeps the completion feature intact, and defends the newline regardless of which provider produced the candidate. It matches the issue's scope ("Stop Enter from silently discarding a newline when the focused suggestion would make no textual change") exactly.Trade-offs, and why they are not problems here
'smart'fixes.acceptSuggestionOnEnteris editor-wide (within the paragraph code editor). Behavior only changes for the exact combination "no-op candidate + auto-triggered popup + Enter"; every other completion path — partial-word accept, Ctrl+Space, Tab — is unchanged. There is no scenario where turning a no-op accept into a newline is a regression.'smart'does not coveradditionalTextEdits(auto-import) or snippet candidates — Monaco treats those as text-changing and still accepts them on Enter. This does not apply to Zeppelin: interpreter completions are mapped as plain-stringinsertTextwith noinsertTextRulesoradditionalTextEdits(completion.service.ts), so those candidate shapes are never produced.How
'smart'works internallyMonaco recomputes a context key
suggestionMakesTextEditwhenever the focused suggestion changes. Under'smart', it gates on: the popup was auto-triggered (state === Auto, i.e. not a manual Ctrl+Space), noadditionalTextEdits, not a snippet, and the replace range length equals the insert-text length. When that gate passes, it compares the editor text against the candidate'sinsertText; if they are identical the key is set tofalse.Enter is bound to
acceptSelectedSuggestion, which requiresVisible && textInputFocus && acceptSuggestionOnEnter && suggestionMakesTextEdit. With the keyfalse, that binding no longer matches, so Enter falls through to the editor's default action — a newline. Ctrl+Space (a manual trigger) never enters thestate === Autogate, so interpreter completion's accept-on-Enter is unaffected; inline ghost-text is a separateregisterInlineCompletionsProvidersubsystem and is likewise untouched.What type of PR is it?
Bug Fix
What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-6710
How should this be tested?
A new Playwright regression,
zeppelin-web-angular/e2e/tests/notebook/monaco-enter-newline.spec.ts, drives the auto-suggest path (typing to let quickSuggestions open the popup, not a manual trigger, since'smart'only applies to auto-triggered popups). It asserts:foobar\nbaz, notfoobarbaz);'smart'only skips no-ops).Verified: the test passes with the fix, and fails deterministically (
foobarandbazmerge onto one line) when the'smart'line is removed — so the regression actually pins the bug.tsc,prettier, andeslintare clean.Screenshots (if appropriate)
2026-09-19.8.42.44.mov
Questions: