diff --git a/Neon Vision Editor/ContentView.swift b/Neon Vision Editor/ContentView.swift index 8f494be..71c79c7 100644 --- a/Neon Vision Editor/ContentView.swift +++ b/Neon Vision Editor/ContentView.swift @@ -914,7 +914,21 @@ struct CustomTextEditor: NSViewRepresentable { let lang = parent.language let scheme = parent.colorScheme - let text = currentText ?? textView?.string ?? "" + let text: String = { + if let currentText = currentText { + return currentText + } + + if Thread.isMainThread { + return textView?.string ?? "" + } + + var result = "" + DispatchQueue.main.sync { + result = textView?.string ?? "" + } + return result + }() // Skip expensive highlighting for very large documents let nsLen = (text as NSString).length diff --git a/Neon Vision Editor/EditorViewModel.swift b/Neon Vision Editor/EditorViewModel.swift index ed350ac..cad735a 100644 --- a/Neon Vision Editor/EditorViewModel.swift +++ b/Neon Vision Editor/EditorViewModel.swift @@ -95,7 +95,8 @@ class EditorViewModel: ObservableObject { guard let index = tabs.firstIndex(where: { $0.id == tab.id }) else { return } let panel = NSSavePanel() panel.nameFieldStringValue = tabs[index].name - panel.allowedContentTypes = [.text, .swiftSource, .pythonScript, .javaScript, .html, .css, .cSource, .json, UTType(importedAs: "public.markdown")] + let mdType = UTType(filenameExtension: "md") ?? .plainText + panel.allowedContentTypes = [.text, .swiftSource, .pythonScript, .javaScript, .html, .css, .cSource, .json, mdType] if panel.runModal() == .OK, let url = panel.url { do {