mirror of
https://github.com/h3pdesign/Neon-Vision-Editor
synced 2026-04-21 13:27:16 +00:00
minor fixes to NSTextView
This commit is contained in:
parent
e4bf47fa08
commit
804c4e62ed
2 changed files with 17 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue