Skip to content

Commit

Permalink
remove extra checks in CodeFileDocument.utType
Browse files Browse the repository at this point in the history
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 (CodeEditApp#1724) for visuals.
  • Loading branch information
plbstl committed Jun 13, 2024
1 parent 357e698 commit 45c39ce
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 28 deletions.
13 changes: 0 additions & 13 deletions CodeEdit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@
6C4104E6297C884F00F472BA /* AboutDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C4104E5297C884F00F472BA /* AboutDetailView.swift */; };
6C4104E9297C970F00F472BA /* AboutDefaultView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C4104E8297C970F00F472BA /* AboutDefaultView.swift */; };
6C48B5C52C0A2835001E9955 /* FileEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C48B5C42C0A2835001E9955 /* FileEncoding.swift */; };
6C48B5C92C0B5F7A001E9955 /* NSTextStorage+isEmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C48B5C72C0B5F7A001E9955 /* NSTextStorage+isEmpty.swift */; };
6C48D8F22972DAFC00D6D205 /* Env+IsFullscreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C48D8F12972DAFC00D6D205 /* Env+IsFullscreen.swift */; };
6C48D8F42972DB1A00D6D205 /* Env+Window.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C48D8F32972DB1A00D6D205 /* Env+Window.swift */; };
6C48D8F72972E5F300D6D205 /* WindowObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C48D8F62972E5F300D6D205 /* WindowObserver.swift */; };
Expand Down Expand Up @@ -893,7 +892,6 @@
6C4104E5297C884F00F472BA /* AboutDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutDetailView.swift; sourceTree = "<group>"; };
6C4104E8297C970F00F472BA /* AboutDefaultView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutDefaultView.swift; sourceTree = "<group>"; };
6C48B5C42C0A2835001E9955 /* FileEncoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileEncoding.swift; sourceTree = "<group>"; };
6C48B5C72C0B5F7A001E9955 /* NSTextStorage+isEmpty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSTextStorage+isEmpty.swift"; sourceTree = "<group>"; };
6C48D8F12972DAFC00D6D205 /* Env+IsFullscreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Env+IsFullscreen.swift"; sourceTree = "<group>"; };
6C48D8F32972DB1A00D6D205 /* Env+Window.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Env+Window.swift"; sourceTree = "<group>"; };
6C48D8F62972E5F300D6D205 /* WindowObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowObserver.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2200,7 +2198,6 @@
588847672992AAB800996D95 /* Array */,
6CBD1BC42978DE3E006639D5 /* Text */,
5831E3D02934036D00D5A6D2 /* NSTableView */,
6C48B5C82C0B5F7A001E9955 /* NSTextStorage */,
5831E3CA2933E86F00D5A6D2 /* View */,
5831E3C72933E7F700D5A6D2 /* Bundle */,
5831E3C62933E7E600D5A6D2 /* Color */,
Expand Down Expand Up @@ -2442,15 +2439,6 @@
path = FindNavigatorResultList;
sourceTree = "<group>";
};
6C48B5C82C0B5F7A001E9955 /* NSTextStorage */ = {
isa = PBXGroup;
children = (
6C48B5C72C0B5F7A001E9955 /* NSTextStorage+isEmpty.swift */,
);
name = NSTextStorage;
path = CodeEdit/Utils/Extensions/NSTextStorage;
sourceTree = SOURCE_ROOT;
};
6C48D8EF2972DAC300D6D205 /* Environment */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3754,7 +3742,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 45c39ce

Please sign in to comment.