CodeEditApp / CodeEditSourceEditor

A code editor view written in Swift powered by tree-sitter.
https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor
MIT License
519 stars 84 forks source link

Using CodeEditSourceEditor does not display text #256

Open wisepmlin opened 4 months ago

wisepmlin commented 4 months ago

Description

截屏2024-07-08 11 48 23

To Reproduce

struct SerialReception: View { @Binding var document: String @State private var language: CodeLanguage = .default @State private var theme: EditorTheme = .wise @State private var font: NSFont = NSFont.monospacedSystemFont(ofSize: 12, weight: .regular) @AppStorage("wrapLines") private var wrapLines: Bool = true @State private var cursorPositions: [CursorPosition] = [] var body: some View { CodeEditSourceEditor( $document, language: language, theme: theme, font: font, tabWidth: 4, lineHeight: 1.2, wrapLines: wrapLines, cursorPositions: $cursorPositions ) } }

Expected Behavior

截屏2024-07-08 11 54 30

Version Information

CodeEditSourceEditor: [e.g. 0.x.y] macOS: [e.g. 15.0] Xcode: [e.g. 16.0 beta]

Additional Context

No response

Screenshots

No response

wisepmlin commented 4 months ago

@ViewBuilder func reception() -> some View { if !viewModel.isObject { TextEditor(text: $viewModel.receivedData) } else { SerialReception(document: $viewModel.receivedData) .id(viewModel.receivedData) } } .id(viewModel.receivedData) An id binding is required to update the UI