Skip to content

Commit

Permalink
Allow text files to be edited even when empty (#1724)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
plbstl authored Jun 22, 2024
1 parent c6a8f8c commit af8c7e1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 17 deletions.
2 changes: 0 additions & 2 deletions CodeEdit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2218,7 +2218,6 @@
588847672992AAB800996D95 /* Array */,
6CBD1BC42978DE3E006639D5 /* Text */,
5831E3D02934036D00D5A6D2 /* NSTableView */,
6C48B5C82C0B5F7A001E9955 /* NSTextStorage */,
5831E3CA2933E86F00D5A6D2 /* View */,
5831E3C72933E7F700D5A6D2 /* Bundle */,
5831E3C62933E7E600D5A6D2 /* Color */,
Expand Down Expand Up @@ -3799,7 +3798,6 @@
6C81916729B3E80700B75C92 /* ModifierKeysObserver.swift in Sources */,
613899BC2B6E709C00A5CAF6 /* URL+FuzzySearchable.swift in Sources */,
611192002B08CCD700D4459B /* SearchIndexer+Memory.swift in Sources */,
6C48B5C92C0B5F7A001E9955 /* NSTextStorage+isEmpty.swift in Sources */,
587B9E8129301D8F00AC7927 /* PublicKey.swift in Sources */,
611191FE2B08CCD200D4459B /* SearchIndexer+File.swift in Sources */,
77A01E302BB4270F00F0EA38 /* ProjectCEWorkspaceSettingsView.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/Features/Documents/CodeFileDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class CodeFileDocument: NSDocument, ObservableObject {
/// - Note: The UTType doesn't necessarily mean the file extension, it can be the MIME
/// type or any other form of data representation.
var utType: UTType? {
if content != nil && content?.isEmpty ?? true {
if content != nil {
return .text
}
guard let fileType, let type = UTType(fileType) else {
Expand Down

This file was deleted.

0 comments on commit af8c7e1

Please sign in to comment.