From 71bb266d3079b88ebdd01904218244b7738a5786 Mon Sep 17 00:00:00 2001 From: Shx Guo Date: Tue, 30 Jul 2024 14:50:17 +0800 Subject: [PATCH 1/4] Merge pull request #558 from RoshanNagaram-eng/roshan/updatelangserver updated lang server version to 1.8.83 --- .../LanguageServer/CodeiumInstallationManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tool/Sources/CodeiumService/LanguageServer/CodeiumInstallationManager.swift b/Tool/Sources/CodeiumService/LanguageServer/CodeiumInstallationManager.swift index e2b25492..7f2c8866 100644 --- a/Tool/Sources/CodeiumService/LanguageServer/CodeiumInstallationManager.swift +++ b/Tool/Sources/CodeiumService/LanguageServer/CodeiumInstallationManager.swift @@ -3,7 +3,7 @@ import Terminal public struct CodeiumInstallationManager { private static var isInstalling = false - static let latestSupportedVersion = "1.8.8" + static let latestSupportedVersion = "1.8.83" public init() {} From c7f20a28a2215943b70e837a2ff1d3278ba27424 Mon Sep 17 00:00:00 2001 From: Shx Guo Date: Tue, 6 Aug 2024 00:22:40 +0800 Subject: [PATCH 2/4] Make variable internal set --- Tool/Sources/Workspace/Filespace.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tool/Sources/Workspace/Filespace.swift b/Tool/Sources/Workspace/Filespace.swift index db88abef..c3a9f085 100644 --- a/Tool/Sources/Workspace/Filespace.swift +++ b/Tool/Sources/Workspace/Filespace.swift @@ -98,7 +98,7 @@ public final class Filespace { Environment.now().timeIntervalSince(lastUpdateTime) > 60 * 3 } - public private(set) var lastUpdateTime: Date = Environment.now() + public internal(set) var lastUpdateTime: Date = Environment.now() private var additionalProperties = FilespacePropertyValues() let fileSaveWatcher: FileSaveWatcher let onClose: (URL) -> Void From 814913407a52c5b796dc44a9f20b03ff442d4470 Mon Sep 17 00:00:00 2001 From: Shx Guo Date: Tue, 6 Aug 2024 15:41:19 +0800 Subject: [PATCH 3/4] Remove redundant closing parenthesis from last line in suggestions --- ...rocessingSuggestionServiceMiddleware.swift | 39 ++++ ...singSuggestionServiceMiddlewareTests.swift | 197 ++++++++++++++++++ 2 files changed, 236 insertions(+) diff --git a/Tool/Sources/SuggestionProvider/PostProcessingSuggestionServiceMiddleware.swift b/Tool/Sources/SuggestionProvider/PostProcessingSuggestionServiceMiddleware.swift index e69e29d2..345dc1ef 100644 --- a/Tool/Sources/SuggestionProvider/PostProcessingSuggestionServiceMiddleware.swift +++ b/Tool/Sources/SuggestionProvider/PostProcessingSuggestionServiceMiddleware.swift @@ -15,6 +15,7 @@ public struct PostProcessingSuggestionServiceMiddleware: SuggestionServiceMiddle var suggestion = $0 if suggestion.text.allSatisfy({ $0.isWhitespace || $0.isNewline }) { return nil } Self.removeTrailingWhitespacesAndNewlines(&suggestion) + Self.removeRedundantClosingParenthesis(&suggestion, lines: request.lines) if !Self.checkIfSuggestionHasNoEffect(suggestion, request: request) { return nil } return suggestion } @@ -28,6 +29,44 @@ public struct PostProcessingSuggestionServiceMiddleware: SuggestionServiceMiddle suggestion.text = String(text) } + /// Remove the parenthesis in the last line of the suggestion if + /// - It contains only closing parenthesis + /// - It's identical to the next line below the range of the suggestion + static func removeRedundantClosingParenthesis( + _ suggestion: inout CodeSuggestion, + lines: [String] + ) { + let nextLineIndex = suggestion.range.end.line + 1 + guard nextLineIndex < lines.endIndex, nextLineIndex >= 0 else { return } + let nextLine = lines[nextLineIndex].dropLast(1) + let lineBreakIndex = suggestion.text.lastIndex(where: { $0.isNewline }) + let lastLineIndex = if let index = lineBreakIndex { + suggestion.text.index(after: index) + } else { + suggestion.text.startIndex + } + guard lastLineIndex < suggestion.text.endIndex else { return } + let lastSuggestionLine = suggestion.text[lastLineIndex...] + guard lastSuggestionLine == nextLine else { return } + + let closingParenthesis: [Character] = [")", "]", "}", ">"] + let validCharacters = Set(closingParenthesis + [" ", ","]) + + let trimmedLastSuggestionLine = nextLine.trimmingCharacters(in: .whitespacesAndNewlines) + guard !trimmedLastSuggestionLine.isEmpty else { return } + + if trimmedLastSuggestionLine == "```" + || trimmedLastSuggestionLine == "\"\"\"" + || trimmedLastSuggestionLine.allSatisfy({ validCharacters.contains($0) }) + { + if let lastIndex = lineBreakIndex { + suggestion.text = String(suggestion.text[..}}", + position: .init(line: 0, character: 1), + range: .init(startPair: (0, 0), endPair: (0, 1)) + ), + ] + } + + let suggestions = try await middleware.getSuggestion( + createRequest("h\n}))>}}\n", .init(line: 0, character: 1)), + configuration: .init( + acceptsRelevantCodeSnippets: true, + mixRelevantCodeSnippetsInSource: true, + acceptsRelevantSnippetsFromOpenedFiles: true + ), + next: handler + ) + + XCTAssertEqual(suggestions, [ + .init( + id: "1", + text: "hello world", + position: .init(line: 0, character: 1), + range: .init(startPair: (0, 0), endPair: (0, 1)) + ), + ]) + } } From 6c69b75db83198aab6fa8da82f111fb2d2fb3bb9 Mon Sep 17 00:00:00 2001 From: Shx Guo Date: Tue, 6 Aug 2024 15:42:39 +0800 Subject: [PATCH 4/4] Bump version to 0.33.7 --- Version.xcconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Version.xcconfig b/Version.xcconfig index 4c9957e3..ce865d72 100644 --- a/Version.xcconfig +++ b/Version.xcconfig @@ -1,3 +1,3 @@ -APP_VERSION = 0.33.5 -APP_BUILD = 394 +APP_VERSION = 0.33.7 +APP_BUILD = 398