@@ -697,4 +697,69 @@ final class SwiftPMIntegrationTests: SourceKitLSPTestCase {
697697 return diagnosticsAfterUpdate. fullReport? . items. map ( \. message) == [ " MY_FLAG set " ]
698698 }
699699 }
700+
701+ func testClearPreparationStatusWhenPackageManifestIsModifiedAndPackageIsOpenedWithoutTrailingSlash( ) async throws {
702+ let project = try await SwiftPMTestProject (
703+ files: [
704+ " MyLibrary/MyLibrary.swift " : """
705+ #if MY_FLAG
706+ public func foo() -> String { " " }
707+ #else
708+ public func foo() -> Int { " " }
709+ #endif
710+ """ ,
711+ " MyExecutable/MyExecutable.swift " : """
712+ import MyLibrary
713+
714+ let 1️⃣x = foo()
715+ """ ,
716+ ] ,
717+ manifest: """
718+ // swift-tools-version: 5.7
719+
720+ import PackageDescription
721+
722+ let package = Package(
723+ name: " MyLibrary " ,
724+ targets: [
725+ .target(name: " MyLibrary " ),
726+ .executableTarget(name: " MyExecutable " , dependencies: [ " MyLibrary " ])
727+ ]
728+ )
729+ """ ,
730+ workspaces: {
731+ [ WorkspaceFolder ( uri: DocumentURI ( try URL ( filePath: $0. filePath, directoryHint: . notDirectory) ) ) ]
732+ } ,
733+ enableBackgroundIndexing: true
734+ )
735+ let ( uri, positions) = try project. openDocument ( " MyExecutable.swift " )
736+ let preEditHoverResponse = try await project. testClient. send (
737+ HoverRequest ( textDocument: TextDocumentIdentifier ( uri) , position: positions [ " 1️⃣ " ] )
738+ )
739+ assertContains ( try XCTUnwrap ( preEditHoverResponse? . contents. markupContent? . value) , " let x: Int " )
740+
741+ try await project. changeFileOnDisk (
742+ " Package.swift " ,
743+ newMarkedContents: """
744+ // swift-tools-version: 5.7
745+
746+ import PackageDescription
747+
748+ let package = Package(
749+ name: " MyLibrary " ,
750+ targets: [
751+ .target(name: " MyLibrary " , swiftSettings: [.define( " MY_FLAG " )]),
752+ .executableTarget(name: " MyExecutable " , dependencies: [ " MyLibrary " ])
753+ ]
754+ )
755+ """
756+ )
757+
758+ try await repeatUntilExpectedResult {
759+ let postEditHoverResponse = try await project. testClient. send (
760+ HoverRequest ( textDocument: TextDocumentIdentifier ( uri) , position: positions [ " 1️⃣ " ] )
761+ )
762+ return try XCTUnwrap ( postEditHoverResponse? . contents. markupContent? . value) . contains ( " let x: String " )
763+ }
764+ }
700765}
0 commit comments