@@ -61,6 +61,33 @@ final class WorkspaceStateRuntimeTests: XCTestCase {
6161 XCTAssertEqual ( changedScanCount, 1 )
6262 }
6363
64+ func testSearchCursorPreservesEarlierConsumerAcrossNoOpAndChangedEvents( ) async throws {
65+ let fixture = try TemporaryFixture ( )
66+ defer { fixture. cleanup ( ) }
67+ let root = fixture. base. appendingPathComponent ( " workspace " , isDirectory: true )
68+ try FileManager . default. createDirectory ( at: root, withIntermediateDirectories: true )
69+ let file = root. appendingPathComponent ( " State.swift " )
70+ try " let value = 1 \n " . write ( to: file, atomically: false , encoding: . utf8)
71+ let store = RuntimeStore ( baseDirectory: fixture. base. appendingPathComponent ( " runtime " ) )
72+ await store. setWorkingDirectoryForTesting ( root)
73+ let runtime = WorkspaceStateRuntime ( runtimeStore: store, startsFSEvents: false )
74+ let initial = try await runtime. snapshot ( path: root. path, contextBudget: 0 )
75+
76+ await runtime. ingestObservedPaths ( [ file. path] )
77+ _ = try await runtime. currentSearchCursor ( path: root. path)
78+ let unchanged = try await runtime. snapshot ( path: root. path, sinceCursor: initial. cursor)
79+ XCTAssertTrue ( unchanged. changes. isEmpty)
80+
81+ try " let value = 2 \n " . write ( to: file, atomically: false , encoding: . utf8)
82+ await runtime. ingestObservedPaths ( [ file. path] )
83+ _ = try await runtime. currentSearchCursor ( path: root. path)
84+ _ = try await runtime. currentSearchCursor ( path: root. path)
85+ let changed = try await runtime. snapshot ( path: root. path, sinceCursor: initial. cursor)
86+ XCTAssertEqual ( changed. changes. map ( \. path) , [ " State.swift " ] )
87+ let repeated = try await runtime. snapshot ( path: root. path, sinceCursor: initial. cursor)
88+ XCTAssertEqual ( repeated. changes, changed. changes)
89+ }
90+
6491 func testCurrentSearchCursorRestoresCheckpointWithoutFilesystemScan( ) async throws {
6592 let fixture = try TemporaryFixture ( )
6693 defer { fixture. cleanup ( ) }
0 commit comments