Skip to content

Commit 0af6265

Browse files
committed
Make text contents always wrap in code block
1 parent 359dc7d commit 0af6265

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Core/Sources/ChatGPTChatTab/Views/ThemedMarkdownText.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ struct ThemedMarkdownText: View {
1515
let content: MarkdownContent
1616

1717
init(_ text: String) {
18-
self.content = .init(text)
18+
content = .init(text)
1919
}
20-
20+
2121
init(_ content: MarkdownContent) {
2222
self.content = content
2323
}
@@ -71,6 +71,8 @@ extension MarkdownUI.Theme {
7171
}
7272
.codeBlock { configuration in
7373
let wrapCode = UserDefaults.shared.value(for: \.wrapCodeInChatCodeBlock)
74+
|| ["plaintext", "text", "markdown", "sh", "bash", "shell", "latex", "tex"]
75+
.contains(configuration.language)
7476

7577
if wrapCode {
7678
AsyncCodeBlockView(

Core/Sources/SuggestionWidget/SuggestionPanelContent/PromptToCodePanelView.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ extension PromptToCodePanelView {
194194
WithPerceptionTracking {
195195
Toggle(
196196
"Always accept and continue",
197-
isOn: $store.isContinuous.animation(.easeInOut(duration: 0.1))
197+
isOn: $store.isContinuous
198+
.animation(.easeInOut(duration: 0.1))
198199
)
199200
.toggleStyle(.checkbox)
200201
}
@@ -319,7 +320,7 @@ extension PromptToCodePanelView {
319320
WithPerceptionTracking {
320321
VStack(spacing: 0) {
321322
Spacer(minLength: 56)
322-
323+
323324
VStack(spacing: 0) {
324325
let language = store.promptToCodeState.source.language
325326
let isAttached = store.promptToCodeState.isAttachedToTarget
@@ -332,7 +333,7 @@ extension PromptToCodePanelView {
332333
if snippetStore.id != lastId {
333334
Divider()
334335
}
335-
336+
336337
SnippetPanelView(
337338
store: snippetStore,
338339
language: language,
@@ -471,6 +472,9 @@ extension PromptToCodePanelView {
471472
var body: some View {
472473
WithPerceptionTracking {
473474
if !store.snippet.modifiedCode.isEmpty {
475+
let wrapCode = wrapCode ||
476+
[CodeLanguage.plaintext, .builtIn(.markdown), .builtIn(.shellscript),
477+
.builtIn(.tex)].contains(language)
474478
if wrapCode {
475479
CodeBlockInContent(
476480
store: store,

Tool/Sources/SharedUIComponents/AsyncCodeBlock.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,4 +524,3 @@ extension AsyncCodeBlock {
524524
return UpdateContent()
525525
.frame(width: 400, height: 200)
526526
}
527-

0 commit comments

Comments
 (0)