Skip to content

Commit 343a66f

Browse files
committed
Update suggestion invalidation
1 parent 4993a5f commit 343a66f

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

Core/Sources/Service/Workspace.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ final class Filespace {
105105
}
106106

107107
// finished typing the whole suggestion when the suggestion has only one line
108-
if editingLine == suggestionFirstLine, suggestionLines.count <= 1 {
108+
if editingLine.hasPrefix(suggestionFirstLine), suggestionLines.count <= 1 {
109109
reset()
110110
return false
111111
}

Core/Tests/ServiceTests/FilespaceSuggestionInvalidationTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
119119
XCTAssertNil(suggestion)
120120
}
121121

122+
func test_finish_typing_the_whole_single_line_suggestion_suggestion_is_incomplete_should_invalidate() async throws {
123+
let filespace = try await prepare(
124+
suggestionText: "hello man",
125+
cursorPosition: .init(line: 1, character: 0)
126+
)
127+
let isValid = await filespace.validateSuggestions(
128+
lines: ["\n", "hello man!!!!!\n", "\n"],
129+
cursorPosition: .init(line: 1, character: 9)
130+
)
131+
XCTAssertFalse(isValid)
132+
let suggestion = await filespace.presentingSuggestion
133+
XCTAssertNil(suggestion)
134+
}
135+
122136
func test_finish_typing_the_whole_multiple_line_suggestion_should_be_valid() async throws {
123137
let filespace = try await prepare(
124138
suggestionText: "hello man\nhow are you?",

Tool/Tests/LangChainTests/ChatAgentTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ private struct FakeChatModel: ChatModel {
55
func generate(
66
prompt: [LangChain.ChatMessage],
77
stops: [String],
8-
callbackManagers: [LangChain.ChainCallbackManager]
8+
callbackManagers: [LangChain.CallbackManager]
99
) async throws -> String {
1010
return "New Message"
1111
}

0 commit comments

Comments
 (0)