Repository navigation
Conversation
Replace all calls openFile with render: false for every file but the last. For a file that was already open, openFile ignored render and always made the tab active before writing the new text, so a large replace switched through every open tab. Now a loaded, already open tab gets its text through its session without being activated when render is false.
bardrop
force-pushed
the
fix-replace-all-background-tabs
branch
from
November 12, 2026 16:03
d276abd to
5f647ed
Compare
Contributor
[Medium impact] The PR appears safe to merge; both previously reported failures are addressed. SummaryUpdates open tabs during replace-all without switching focus.
Both previous findings are addressed. No new actionable issues were found. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Background replacement] --> B{File shown in a pane?}
B -->|Yes| C[Update that pane's editor]
C --> D[Listener syncs text and schedules autosave]
B -->|No| E[Update stored text]
E --> F[Schedule background autosave]
F --> G{Still open and unsaved?}
G -->|Yes| H[Save current text]
G -->|No| I[Skip save]
Reviews (2) · Last reviewed commit: "fix(search): keep split panes and autosa..." · Reviewed by Greptile |
Edit the live view of a pane that shows the tab, so focusing it later does not bring back the old text. Hidden tabs get autosave scheduled, since no view listener runs for them.
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.
Fixes #3043
Problem
Replace all in "Search in files" calls
openFile(url, { render, text })for each replaced file, withrender: falsefor every file except the last. When a file was already open,openFileignoredrender: it always calledmakeActive()on the tab and then wrote the new text into the live editor. So a replace over many open tabs switched through every one of them, which is what the video in the issue shows, and it is slow.Fix
In the "file already open" path of
openFile, whenrender === false, text is given, and the tab is loaded (and no pane, cursor or encoding change is asked for), the new text goes throughexistingFile.session.setValue()without activating the tab. That proxy already handles inactive tabs: it updates the stored state and marks the file as edited/unsaved. The last file (render: true) still opens as before. Tabs that are not loaded yet keep the old path.Tests
Three new cases in
tests/unit/openFileCancellation.test.js(the file that already loads the realopenFilemodule):makeActiveand sets the text (fails before)rendernot false: still switches and dispatches as beforenpx vitest run: all pass except the 4 LSP test files that need the@codemirror/lsp-clientsubmodule (same on main).biome checkclean.This branch is separate from #3048 (empty replacement); they touch different lines and merge cleanly.