Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix deterministic workspace indexing and search#2178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jkaunert
wants to merge
1
commit into
CodeEditApp:mainChoose a base branch
from
jkaunert:fix/issue-1993-indexing-search-contracts
base:main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Uh oh!
There was an error while loading. Please reload this page.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
49 changes: 22 additions & 27 deletions
49 CodeEdit/Features/Documents/WorkspaceDocument/WorkspaceDocument+Find.swift
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
146 changes: 101 additions & 45 deletions
146 CodeEdit/Features/Documents/WorkspaceDocument/WorkspaceDocument+Index.swift
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
5 changes: 5 additions & 0 deletions
5 CodeEdit/Features/Documents/WorkspaceDocument/WorkspaceDocument+SearchState.swift
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
26 changes: 5 additions & 21 deletions
26 CodeEditTests/Features/Documents/WorkspaceDocument+SearchState+FindAndReplaceTests.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -9,7 +9,7 @@ import XCTest | ||
| @testable import CodeEdit | ||
| @MainActor | ||
| final class FindAndReplaceTests: XCTestCase { // swiftlint:disable:this type_body_length | ||
| final class FindAndReplaceTests: XCTestCase { | ||
jkaunert marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| private var directory: URL! | ||
| private var files: [CEWorkspaceFile] = [] | ||
| private var mockWorkspace: WorkspaceDocument! | ||
| @@ -64,20 +64,11 @@ final class FindAndReplaceTests: XCTestCase { // swiftlint:disable:this type_bod | ||
| files[1].parent = folder1File | ||
| files[2].parent = folder2File | ||
| mockWorkspace.searchState?.addProjectToIndex() | ||
| await mockWorkspace.searchState?.indexProject() | ||
| // NOTE: This is a temporary solution. In the future, a file watcher should track file updates | ||
| // and trigger an index update. | ||
| let startTime = Date() | ||
| let timeoutInSeconds = 2.0 | ||
| while searchState.indexStatus != .done { | ||
| // Check every 0.1 seconds for index completion | ||
| try? await Task.sleep(nanoseconds: 100_000_000) // 0.1 seconds | ||
| if Date().timeIntervalSince(startTime) > timeoutInSeconds { | ||
| XCTFail("TIMEOUT: Indexing took to long or did not complete.") | ||
| return | ||
| } | ||
| } | ||
| XCTAssertEqual(searchState.indexStatus, .done) | ||
| // Retrieve indexed documents from the indexer | ||
| guard let documentsInIndex = searchState.indexer?.documents() else { | ||
| @@ -99,15 +90,8 @@ final class FindAndReplaceTests: XCTestCase { // swiftlint:disable:this type_bod | ||
| // IMPORTANT: | ||
| // This is only a temporary solution, in the feature a file watcher would track the file update | ||
| // and trigger a index update. | ||
| searchState.addProjectToIndex() | ||
| let startTime = Date() | ||
| while searchState.indexStatus != .done { | ||
| try? await Task.sleep(nanoseconds: 100_000_000) | ||
| if Date().timeIntervalSince(startTime) > 2.0 { | ||
| XCTFail("TIMEOUT: Indexing took to long or did not complete.") | ||
| return | ||
| } | ||
| } | ||
| await searchState.indexProject() | ||
| XCTAssertEqual(searchState.indexStatus, .done) | ||
| } | ||
| func testFindAndReplace() async { | ||
13 changes: 2 additions & 11 deletions
13 CodeEditTests/Features/Documents/WorkspaceDocument+SearchState+FindTests.swift
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
13 changes: 2 additions & 11 deletions
13 CodeEditTests/Features/Documents/WorkspaceDocument+SearchState+IndexTests.swift
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
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.
Uh oh!
There was an error while loading. Please reload this page.