Repository navigation
add change spelling language command; apply dictionary changes live - #18766
Conversation
Edit > Change Spelling Language... (also in the command palette) opens a small picker built on SpellingLanguageSelectWidget and applies the choice immediately. Two things previously forced a restart: the realtime spell checker ignored dictionary changes (no-op handler) and kept per-session word caches, and the Spelling prefs pane flagged a language change as requiring a desktop restart. Both are fixed. Addresses #12223
RStudio E2E - all platforms1 test(s) failed
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
Persist the effective dictionary, recheck after confirmed preference changes, and reject stale spelling responses. Cover project overrides and delayed responses in the spelling tests. Addresses #12223.
Replace complete preference layers in every editor window so removed project overrides fall back correctly. Retain installed dictionary metadata for reopened language pickers, with unit and desktop regression coverage. Addresses #12223.
gtritchie
left a comment
There was a problem hiding this comment.
No blocking issues. 0 blocking, 0 follow-up, 1 nit
🔴 must be resolved before merge. 🟠 is real but not merge-blocking — either address it here or open an issue to do so later. 🟡 is optional.
- 🟡
src/gwt/src/org/rstudio/studio/client/common/spelling/ui/ChangeSpellingLanguageDialog.java:101— PR description says the opposite of what this branch does when a project sets its own dictionary
|
|
||
| // Persist the effective layer so the server and the picker agree, and | ||
| // leave the global default alone when this project overrides it. | ||
| if (language.hasProjectValue()) |
There was a problem hiding this comment.
🟡 The PR body says applying the change sets the global pref and leaves the .Rproj alone. When the project sets its own dictionary, this branch does the reverse.
Fix the "Approach" paragraph to match: when the project overrides the dictionary, the dialog rewrites SpellingDictionary: in the .Rproj and doesn't touch the global pref.
Why
The e2e test "a project dictionary change reaches the server and persists in the project" checks that the .Rproj gets written, so the code does this on purpose. Only the description is wrong. It still matters for reviewers, because the .Rproj is often under version control. Picking a language from an Edit-menu command now produces a diff in a committed file.
There was a problem hiding this comment.
Good catch, the description was written against the first commit and the follow-ups changed this. Updated the PR body: with a project override the dialog rewrites SpellingDictionary: in the .Rproj (same write as Project Options > Spelling) and leaves the global pref alone, with a note that this shows up as a diff when the .Rproj is under version control. Without an override it writes only the global pref. Also refreshed the Testing section to cover the tests added since.
gtritchie
left a comment
There was a problem hiding this comment.
One nit but otherwise LGTM!
Two linux CI flakes from the PR #18802 run (34712089464): - spelling_language_switch "rechecks an open detached editor" looked up the satellite's Ace editor right after 'domcontentloaded', which is the popup's initial document -- GWT mounts the editor later. The lookup throws until then, and expect.poll propagates a throw instead of retrying, so the test died ~70ms after the popup opened. Red on desktop-linux since #18766 and now on linux-server too. Poll with toPass so the throw is retried. - highlight_active_tabs read the selected tab's indicator geometry once. Selecting a partly hidden tab animates the strip to reveal it, and DocTabLayoutPanel keeps the clipped (position: absolute) variant until that scroll settles, so a one-shot read could see 'absolute' where the test expects 'fixed'. Poll the geometry until it settles.
Intent
Switching the spelling dictionary takes one step and takes effect immediately:
Fixes #12223.
Approach
Two things made the old flow need a restart:
RealtimeSpellCheckerregistered a no-op handler forspelling_dictionary_languagechanges and kept per-sessioncorrectWords/incorrectWordscaches, so a stale "misspelled" verdict survived the switch. It now clears both caches and re-checks the document (invalidateAllWords()) when the language changes.SpellingPreferencesPane.onApply()flagged a language change as requiring a desktop restart; that flag is dropped (custom-dictionary edits keep it).The new
changeSpellingLanguagecommand is handled inWorkbenchScreennext toshowSpellingOptions;ChangeSpellingLanguageDialogreusesSpellingLanguageSelectWidget. The dialog persists whichever layer is currently in effect, so the picker and the server agree afterwards:SpellingDictionary:in the.Rproj(the same write Project Options > Spelling performs) and leaves the global pref alone. Note that this produces a diff in the.Rprojif it is under version control.Follow-up commits on this branch harden the live update:
SpellingServicere-checks only after the server confirms the pref or project-config write, and tags in-flightcheck_spelling/ suggestion requests with a dictionary generation so a slow response from the old dictionary is retried rather than cached.full_layer) replace the layer wholesale in every editor window, so clearing a project override falls back to the global default instead of leaving a stale project value behind.spellingPrefsContext, so a reopened picker lists the new dictionaries.Testing
New Playwright suite
tests/panes/editor/spelling_language_switch.test.ts:SpellingDictionary: en_US, switches via the dialog and checks the.Rprojnow readsSpellingDictionary: en_GB;check_spellingresponse and confirms it cannot restore stale results;New GWT unit tests in
PrefsTestscover full-layer replacement.rmarkdown.test.tsandglobal_prefs_panels.test.tsstill pass locally in desktop-dev mode.Checklist