Skip to content

Commit af8c7e1

Browse files
authored
Allow text files to be edited even when empty (#1724)
* fix: allow text files to be edited even when empty * wip: remove the need for loading file contents into memory * xcode updated packages - CodeEditTextView 0.7.3 -> 0.7.4 - CodeEditSourceEditor 0.7.2 -> 0.7.3 - CodeEditLanguages 0.1.18 -> 0.1.19 * Merge branch 'main' of https://github.com/CodeEditApp/CodeEdit into allow-edit-text-file-when-contents-in-empty * remove extra checks in `CodeFileDocument.utType` Only check for when `CodeFileDocument.content` is not nil. If the content is an empty string, it means we're viewing an empty text file, which is a predictable behavior. Also, the extra checks cause unexpected behaviors. Check the related pull request (#1724) for visuals. * redo changes made in 45c39ce
1 parent c6a8f8c commit af8c7e1

File tree

3 files changed

+1
-17
lines changed

3 files changed

+1
-17
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,7 +2218,6 @@
22182218
588847672992AAB800996D95 /* Array */,
22192219
6CBD1BC42978DE3E006639D5 /* Text */,
22202220
5831E3D02934036D00D5A6D2 /* NSTableView */,
2221-
6C48B5C82C0B5F7A001E9955 /* NSTextStorage */,
22222221
5831E3CA2933E86F00D5A6D2 /* View */,
22232222
5831E3C72933E7F700D5A6D2 /* Bundle */,
22242223
5831E3C62933E7E600D5A6D2 /* Color */,
@@ -3799,7 +3798,6 @@
37993798
6C81916729B3E80700B75C92 /* ModifierKeysObserver.swift in Sources */,
38003799
613899BC2B6E709C00A5CAF6 /* URL+FuzzySearchable.swift in Sources */,
38013800
611192002B08CCD700D4459B /* SearchIndexer+Memory.swift in Sources */,
3802-
6C48B5C92C0B5F7A001E9955 /* NSTextStorage+isEmpty.swift in Sources */,
38033801
587B9E8129301D8F00AC7927 /* PublicKey.swift in Sources */,
38043802
611191FE2B08CCD200D4459B /* SearchIndexer+File.swift in Sources */,
38053803
77A01E302BB4270F00F0EA38 /* ProjectCEWorkspaceSettingsView.swift in Sources */,

CodeEdit/Features/Documents/CodeFileDocument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ final class CodeFileDocument: NSDocument, ObservableObject {
6565
/// - Note: The UTType doesn't necessarily mean the file extension, it can be the MIME
6666
/// type or any other form of data representation.
6767
var utType: UTType? {
68-
if content != nil && content?.isEmpty ?? true {
68+
if content != nil {
6969
return .text
7070
}
7171
guard let fileType, let type = UTType(fileType) else {

CodeEdit/Utils/Extensions/NSTextStorage/NSTextStorage+isEmpty.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)