Repository navigation
The name index reads a clean document's first edit from the document, not from disk - #204
Merged
Merged
Conversation
The palette runs a command with no argument, and lists View as Text only while a table has focus. A table is a webview, so there is no active text editor to take the file from, and the command does nothing. The new test opens the JSON dictionary's table, runs View as Text with no argument and expects its text in a second tab: it fails on this commit. Two more pin the palette's View as Table: from a text editor it opens the table beside it, and on a compressed dictionary already in its table it leaves the one tab as it is.
The palette passes no argument, and both toggle commands fell back to the active text editor's document. The palette lists View as Text only while a table has focus, when there is no active text editor (a table is a webview), so the command found no file and did nothing. Both commands now take the file from the active tab, a custom editor's or a text editor's, and only then from the active text editor.
Once a search has built the window's name index, every content change of an open data source reindexes its file from the document's text. VS Code reports an edit to a clean document while it still reads clean, and the reindex, which asks isDirty alone, reads that first edit's file from disk instead. nameIndexFirstEdit builds the index through the real search command, then makes one edit to a clean JSON dictionary: no read of the file is made, and a rename made in that one edit is what the search offers, not the name the file had. Both fail on this commit. With them, the Search Data Source Entries suite held back from #196 (the real command and QuickPick, which leaves the index built), its QuickPick helpers in tools/quickPicks.ts, and tools/webviewTap.ts as #196 has it.
The name index reindexes a data source on each of its content changes, from the document's text while the document is dirty. VS Code reports an edit to a clean document while it still reads clean, and its dirty flag only after, as an event with no change, so that first edit's reindex read the whole file from disk and kept the names the file had: a rename made in one edit was not what the search offered until the next edit or a save. onDidChangeTextDocument now hands reindexFile the document, and the reindex that answers it reads that document's text whatever its flag says. Any other reindex (the folder's watcher) reads as before: a dirty open document's text, else the file. The decision is documentText.ts's, unit-tested.
Both add ## Unreleased to CHANGELOG.md: one heading now, #193's bullet first, then this one's.
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.
Includes #193 (merged in for their shared CHANGELOG heading). Merge #193 first, or this one alone brings both.
Once a search has built the window's name index, the first edit of a clean data source makes the index read that file from disk instead of the document's text.
VS Code reports an edit to a clean document while the document still reads clean, and its dirty flag only after it, as an event carrying no change (
[{changes:1, dirty:false}, {changes:0, dirty:true}], measured on CI in the #196 probe).reindexFile→dirtyBytesOf(src/host/nameIndex.ts) askedisDirtyalone, so that first edit's reindex found no unsaved text and scanned the file: a whole-file read on the first edit after every open or save, and the file's old names in the index for that edit.Found by #196: with the Search Data Source Entries suite run first,
jsonBaselineFollowsDisk"an edit to a clean document does not read the file" counted that read and failed.Tests first
The first commit is tests only (red run below):
nameIndexFirstEdit.test.ts: builds the index through the real search command, then makes one edit to a clean JSON dictionary: (a) no read of the file (a counting file system, asjsonBaselineFollowsDiskcounts); (b) a rename made in that one edit is what the search offers, not the old name.searchDataSources.test.ts, held back from Test the host's navigation and command routes in a real window #196, ontools/quickPicks.ts;tools/webviewTap.tsas Test the host's navigation and command routes in a real window #196 has it (same content).Red, run 41364249428 at 7de21da (211 passing, 3 failing): (a) fails with one read of the file; (b) fails too: after the one-edit rename the search still offered only
Number, neverNumberRenamedOnce; andjsonBaselineFollowsDisk's no-read test fails as in #196.Fix
extension.ts:onDidChangeTextDocument(content changes only, as before) passes the document toreindexFile.nameIndex.ts: the reindex that answers that change reads that document's text, whatever its dirty flag says yet; it is held for that reindex alone. Any other reindex (the folder's watcher) reads as before: a dirty open document's text, else the file through the shared cache.documentText.ts(new, vscode-free): the decision,textOverDisk, unit-tested intest/documentText.test.ts.CHANGELOG.md:## Unreleasedwith one bullet (View as Text from the Command Palette opens the dictionary's text #193 adds the same heading, so a trivial merge is expected).Green, run 41364583282 at 6cc8777: 214 passing, 9 pending, 0 failing; both new tests, the search suite and
jsonBaselineFollowsDiskpass. Locallynpm run verifypasses (1312 unit tests).