diff --git a/apps/swift-ios/Features/Chat/FeatureComposerView.swift b/apps/swift-ios/Features/Chat/FeatureComposerView.swift index 146485c38dab..6cd0bc0c36c7 100644 --- a/apps/swift-ios/Features/Chat/FeatureComposerView.swift +++ b/apps/swift-ios/Features/Chat/FeatureComposerView.swift @@ -483,18 +483,21 @@ struct FeatureComposerView: View { case let .path(entry): replacement = FeatureComposerFileLinkSerializer.markdownLink(for: entry.path) + " " } - textSelectionRequest = FeatureComposerTextSelectionRequest( - location: FeatureComposerTextSelectionPolicy.cursorLocation( - afterReplacing: trigger.range, - in: text, - with: replacement - ) + let nextCursorLocation = FeatureComposerTextSelectionPolicy.cursorLocation( + afterReplacing: trigger.range, + in: text, + with: replacement ) text = FeatureComposerTriggerParser.replacing( trigger.range, in: text, with: replacement ) + // Publish the text first so the representable cannot consume and clamp + // this request against the pre-replacement draft. + textSelectionRequest = FeatureComposerTextSelectionRequest( + location: nextCursorLocation + ) pathEntries = [] pathSearchError = nil Task { @MainActor in