Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
396 changes: 84 additions & 312 deletions CodeEdit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 17 additions & 22 deletions CodeEdit.xcodeproj/xcshareddata/xcschemes/CodeEdit.xcscheme
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
version = "1.3">
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand All @@ -27,6 +27,12 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:CodeEditTests/CodeEditTestPlan.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO">
Expand Down Expand Up @@ -89,29 +95,18 @@
<Test
Identifier = "DocumentsUnitTests/testSplitViewControllerStopSnappedWhenWidthIsHigherAppropriateRange()">
</Test>
<Test
Identifier = "WelcomeModuleUnitTests">
</Test>
<Test
Identifier = "WelcomeModuleUnitTests/testRecentJSFileDarkSnapshot()">
</Test>
<Test
Identifier = "WelcomeModuleUnitTests/testRecentJSFileLightSnapshot()">
</Test>
<Test
Identifier = "WelcomeModuleUnitTests/testRecentProjectItemDarkSnapshot()">
</Test>
<Test
Identifier = "WelcomeModuleUnitTests/testRecentProjectItemLightSnapshot()">
</Test>
<Test
Identifier = "WelcomeModuleUnitTests/testWelcomeActionViewDarkSnapshot()">
</Test>
<Test
Identifier = "WelcomeModuleUnitTests/testWelcomeActionViewLightSnapshot()">
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6C769F932B49BF1600ADF98B"
BuildableName = "CodeEditUITests.xctest"
BlueprintName = "CodeEditUITests"
ReferencedContainer = "container:CodeEdit.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
33 changes: 7 additions & 26 deletions CodeEdit/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
NSApp.closeWindow(.welcome, .about)

DispatchQueue.main.async {
var needToHandleOpen = true
let wereFilesOpened = CommandLine.openArgumentFiles()

// If no windows were reopened by NSQuitAlwaysKeepsWindows, do default behavior.
// Non-WindowGroup SwiftUI Windows are still in NSApp.windows when they are closed,
// So we need to think about those.
if NSApp.windows.count > NSApp.openSwiftUIWindows {
needToHandleOpen = false
}

for index in 0..<CommandLine.arguments.count {
if CommandLine.arguments[index] == "--open" && (index + 1) < CommandLine.arguments.count {
let path = CommandLine.arguments[index+1]
let url = URL(fileURLWithPath: path)

CodeEditDocumentController.shared.reopenDocument(
for: url,
withContentsOf: url,
display: true
) { document, _, _ in
document?.windowControllers.first?.synchronizeWindowTitleWithDocumentName()
}

needToHandleOpen = false
}
}

if needToHandleOpen {
if !wereFilesOpened {
self.handleOpen()
}

// Apply UI testing modifications
#if DEBUG
CommandLine.useUITestModifiers()
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ struct CEContentUnavailableView<Actions: View>: View {
.frame(maxWidth: .infinity, maxHeight: .infinity)
.contentShape(Rectangle())
.controlSize(.small)
.accessibilityLabel(label)
.accessibilityHint(description ?? "")
.accessibilityElement(children: .combine)
.accessibilityIdentifier("CEContentUnavailableView " + label)
}

var body: some View {
Expand Down
103 changes: 103 additions & 0 deletions CodeEdit/Features/Documents/Views/WorkspaceCodeFileView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// WorkspaceCodeFileView.swift
// CodeEdit
//
// Created by Pavel Kasila on 20.03.22.
//

import SwiftUI
import UniformTypeIdentifiers
import CodeEditSourceEditor

struct WorkspaceCodeFileView: View {

@EnvironmentObject private var editorManager: EditorManager

@EnvironmentObject private var editor: Editor

var file: CEWorkspaceFile
var textViewCoordinators: [TextViewCoordinator] = []

@State private var update: Bool = false

@ViewBuilder var codeView: some View {
if let document = file.fileDocument {
Group {
switch document.typeOfFile {
case .some(.text), .some(.data):
CodeFileView(codeFile: document, textViewCoordinators: textViewCoordinators)
default:
otherFileView(document, for: file)
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
} else {
if update {
Spacer()
}
Spacer()
VStack(spacing: 10) {
ProgressView()
Text("Opening \(file.name)...")
}
Spacer()
.onAppear {
Task.detached {
let contentType = try await file.url.resourceValues(forKeys: [.contentTypeKey]).contentType
let codeFile = try await CodeFileDocument(
for: file.url,
withContentsOf: file.url,
ofType: contentType?.identifier ?? ""
)
await MainActor.run {
file.fileDocument = codeFile
CodeEditDocumentController.shared.addDocument(codeFile)
update.toggle()
}
}
}
}
}

@ViewBuilder
private func otherFileView(
_ otherFile: CodeFileDocument,
for item: CEWorkspaceFile
) -> some View {
VStack(spacing: 0) {
if let url = otherFile.previewItemURL,
let image = NSImage(contentsOf: url),
otherFile.typeOfFile == .image {
GeometryReader { proxy in
if image.size.width > proxy.size.width || image.size.height > proxy.size.height {
OtherFileView(otherFile)
} else {
OtherFileView(otherFile)
.frame(
width: proxy.size.width * (proxy.size.width / image.size.width),
height: proxy.size.height
)
.position(x: proxy.frame(in: .local).midX, y: proxy.frame(in: .local).midY)
}
}
} else {
OtherFileView(otherFile)
}
}
}

var body: some View {
codeView
.frame(maxWidth: .infinity, maxHeight: .infinity)
.onHover { hover in
DispatchQueue.main.async {
if hover {
NSCursor.iBeam.push()
} else {
NSCursor.pop()
}
}
}
.accessibilityIdentifier("WorkspaceCodeFileView " + file.id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ struct EditorTabView: View {
}
}
.id(item.id)
.accessibilityIdentifier("EditorTabView" + item.id + (isTemporary ? " - temporary" : ""))
.tabBarContextMenu(item: item, isTemporary: isTemporary)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct EditorTabBarLeadingAccessories: View {

var body: some View {
HStack(spacing: 0) {
if let otherEditor {
if otherEditor != nil {
EditorTabBarAccessoryIcon(
icon: .init(systemName: "multiply"),
action: { [weak editor] in
Expand All @@ -33,6 +33,7 @@ struct EditorTabBarLeadingAccessories: View {
.help("Close this Editor")
.disabled(editorManager.isFocusingActiveEditor)
.opacity(editorManager.isFocusingActiveEditor ? 0.5 : 1)
.accessibilityLabel("Close this Editor")

EditorTabBarAccessoryIcon(
icon: .init(
Expand All @@ -50,6 +51,11 @@ struct EditorTabBarLeadingAccessories: View {
? "Unfocus this Editor"
: "Focus this Editor"
)
.accessibilityLabel(
editorManager.isFocusingActiveEditor
? "Unfocus this Editor"
: "Focus this Editor"
)

Divider()
.frame(height: 10)
Expand Down Expand Up @@ -83,6 +89,7 @@ struct EditorTabBarLeadingAccessories: View {
}
.disabled(editor.historyOffset == editor.history.count-1 || editor.history.isEmpty)
.help("Navigate back")
.accessibilityLabel("Navigate Back")

Menu {
ForEach(
Expand Down Expand Up @@ -110,6 +117,7 @@ struct EditorTabBarLeadingAccessories: View {
}
.disabled(editor.historyOffset == 0)
.help("Navigate forward")
.accessibilityLabel("Navigate Forward")
}
.buttonStyle(.icon)
.controlSize(.small)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct EditorTabBarTrailingAccessories: View {
Image(symbol: "square.split.horizontal.plus")
}
.help("Split Vertically")
.accessibilityLabel("Split Vertically")

case (.vertical, true), (.horizontal, false):
Button {
Expand All @@ -56,6 +57,7 @@ struct EditorTabBarTrailingAccessories: View {
Image(symbol: "square.split.vertical.plus")
}
.help("Split Horizontally")
.accessibilityLabel("Split Horizontally")

default:
EmptyView()
Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/Features/Editor/Views/CodeFileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ struct CodeFileView: View {
undoManager: undoManager,
coordinators: textViewCoordinators
)

.id(codeFile.fileURL)
.background {
if colorScheme == .dark {
Expand All @@ -148,6 +147,7 @@ struct CodeFileView: View {
.onChange(of: bracketHighlight) { _ in
bracketPairHighlight = getBracketPairHighlight()
}
.accessibilityIdentifier("CodeFileView")
}

private func getLanguage() -> CodeLanguage {
Expand Down
1 change: 1 addition & 0 deletions CodeEdit/Features/Editor/Views/EditorAreaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ struct EditorAreaView: View {
editor.temporaryTab = editor.tabs[0]
}
}
.accessibilityIdentifier("EditorView")
}
}
2 changes: 2 additions & 0 deletions CodeEdit/Features/Editor/Views/EditorLayoutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct EditorLayoutView: View {
SubEditorLayoutView(data: data, focus: $focus)
}
}
.accessibilityIdentifier("EditorLayoutView")
}

struct SubEditorLayoutView: View {
Expand All @@ -56,6 +57,7 @@ struct EditorLayoutView: View {
splitView
}
.edgesIgnoringSafeArea([.top, .bottom])
.accessibilityIdentifier("SubEditorLayoutView " + data.axis.description)
}

var splitView: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ struct NavigatorAreaView: View {
}
}
.environmentObject(workspace)
.accessibilityIdentifier("NavigatorAreaView")
}
}
1 change: 1 addition & 0 deletions CodeEdit/Features/UtilityArea/Views/UtilityAreaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ struct UtilityAreaView: View {
.padding(.vertical, 8)
.frame(maxHeight: 27)
}
.accessibilityIdentifier("UtilityAreaView")
}
}
Loading