Skip to content

Commit 51729ed

Browse files
committed
Update to return empty list for suggestion request on disabled languages
1 parent 1b3669f commit 51729ed

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Core/Sources/SuggestionService/SuggestionService.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
2-
import UserDefaultsObserver
32
import Preferences
43
import SuggestionModel
4+
import UserDefaultsObserver
55

66
public protocol SuggestionServiceType {
77
func getSuggestions(
@@ -42,7 +42,7 @@ public final class SuggestionService: SuggestionServiceType {
4242
public init(projectRootURL: URL, onServiceLaunched: @escaping (SuggestionServiceType) -> Void) {
4343
self.projectRootURL = projectRootURL
4444
self.onServiceLaunched = onServiceLaunched
45-
45+
4646
providerChangeObserver.onChange = { [weak self] in
4747
guard let self else { return }
4848
suggestionProvider = buildService()
@@ -75,7 +75,14 @@ public extension SuggestionService {
7575
usesTabsForIndentation: Bool,
7676
ignoreSpaceOnlySuggestions: Bool
7777
) async throws -> [SuggestionModel.CodeSuggestion] {
78-
try await suggestionProvider.getSuggestions(
78+
let language = languageIdentifierFromFileURL(fileURL)
79+
if UserDefaults.shared.value(for: \.suggestionFeatureDisabledLanguageList)
80+
.contains(where: { $0 == language.rawValue })
81+
{
82+
return []
83+
}
84+
85+
return try await suggestionProvider.getSuggestions(
7986
fileURL: fileURL,
8087
content: content,
8188
cursorPosition: cursorPosition,

0 commit comments

Comments
 (0)