Skip to content

Commit 7a34ee1

Browse files
committed
Update names of settings keys
1 parent 8164984 commit 7a34ee1

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

Core/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/LegacyActiveDocumentChatContextCollector.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public struct LegacyActiveDocumentChatContextCollector: ChatContextCollector {
3030
{
3131
let lines = content.editorContent?.lines.count ?? 0
3232
let maxLine = UserDefaults.shared
33-
.value(for: \.maxEmbeddableFileInChatContextLineCount)
33+
.value(for: \.maxFocusedCodeLineCount)
3434
if lines <= maxLine {
3535
return """
3636
File Content:```\(content.language.rawValue)
@@ -48,7 +48,7 @@ public struct LegacyActiveDocumentChatContextCollector: ChatContextCollector {
4848
}
4949
}
5050

51-
if UserDefaults.shared.value(for: \.useSelectionScopeByDefaultInChatContext) {
51+
if UserDefaults.shared.value(for: \.useCodeScopeByDefaultInChatContext) {
5252
return """
5353
Selected Code \
5454
(start from line \(selectionRange.start.line)):```\(content.language.rawValue)

Core/Sources/ChatGPTChatTab/ChatPanel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private struct StopRespondingButton: View {
104104
}
105105

106106
private struct Instruction: View {
107-
@AppStorage(\.useSelectionScopeByDefaultInChatContext)
107+
@AppStorage(\.useCodeScopeByDefaultInChatContext)
108108
var useCodeScopeByDefaultInChatContext
109109

110110
var body: some View {

Core/Sources/ChatService/DynamicContextController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class DynamicContextController {
3535
func updatePromptToMatchContent(systemPrompt: String, content: String) async throws {
3636
var content = content
3737
var scopes = Self.parseScopes(&content)
38-
if UserDefaults.shared.value(for: \.useSelectionScopeByDefaultInChatContext) {
38+
if UserDefaults.shared.value(for: \.useCodeScopeByDefaultInChatContext) {
3939
scopes.insert("code")
4040
} else {
4141
scopes.insert("file")

Core/Sources/HostApp/FeatureSettings/ChatSettingsView.swift

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ struct ChatSettingsView: View {
1010
@AppStorage(\.chatGPTMaxMessageCount) var chatGPTMaxMessageCount
1111
@AppStorage(\.chatFontSize) var chatFontSize
1212
@AppStorage(\.chatCodeFontSize) var chatCodeFontSize
13-
@AppStorage(\.embedFileContentInChatContextIfNoSelection)
14-
var embedFileContentInChatContextIfNoSelection
15-
@AppStorage(\.maxEmbeddableFileInChatContextLineCount)
16-
var maxEmbeddableFileInChatContextLineCount
17-
@AppStorage(\.useSelectionScopeByDefaultInChatContext)
18-
var useSelectionScopeByDefaultInChatContext
13+
@AppStorage(\.maxFocusedCodeLineCount)
14+
var maxFocusedCodeLineCount
15+
@AppStorage(\.useCodeScopeByDefaultInChatContext)
16+
var useCodeScopeByDefaultInChatContext
1917

2018
@AppStorage(\.chatFeatureProvider) var chatFeatureProvider
2119
@AppStorage(\.chatGPTModel) var chatGPTModel
@@ -188,21 +186,17 @@ struct ChatSettingsView: View {
188186
@ViewBuilder
189187
var contextForm: some View {
190188
Form {
191-
Toggle(isOn: $settings.useSelectionScopeByDefaultInChatContext) {
192-
Text("Use selection scope by default in chat context.")
193-
}
194-
195-
Toggle(isOn: $settings.embedFileContentInChatContextIfNoSelection) {
196-
Text("Embed file content in chat context if no code is selected.")
189+
Toggle(isOn: $settings.useCodeScopeByDefaultInChatContext) {
190+
Text("Use @code scope by default in chat context.")
197191
}
198192

199193
HStack {
200194
TextField(text: .init(get: {
201-
"\(Int(settings.maxEmbeddableFileInChatContextLineCount))"
195+
"\(Int(settings.maxFocusedCodeLineCount))"
202196
}, set: {
203-
settings.maxEmbeddableFileInChatContextLineCount = Int($0) ?? 0
197+
settings.maxFocusedCodeLineCount = Int($0) ?? 0
204198
})) {
205-
Text("Max embeddable file")
199+
Text("Max focused code line count in chat context")
206200
}
207201
.textFieldStyle(.roundedBorder)
208202

Tool/Sources/Preferences/Keys.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ public extension UserDefaultPreferenceKeys {
274274
.init(defaultValue: false, key: "EmbedFileContentInChatContextIfNoSelection")
275275
}
276276

277-
var maxEmbeddableFileInChatContextLineCount: PreferenceKey<Int> {
277+
var maxFocusedCodeLineCount: PreferenceKey<Int> {
278278
.init(defaultValue: 100, key: "MaxEmbeddableFileInChatContextLineCount")
279279
}
280280

281-
var useSelectionScopeByDefaultInChatContext: PreferenceKey<Bool> {
281+
var useCodeScopeByDefaultInChatContext: PreferenceKey<Bool> {
282282
.init(defaultValue: true, key: "UseSelectionScopeByDefaultInChatContext")
283283
}
284284

0 commit comments

Comments
 (0)