Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
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
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ identifier_name:
# paths to ignore during linting.
excluded:
- CodeEditModules/.build # Where Swift Package Manager checks out dependency sources
- DerivedData
- DerivedData

opt_in_rules:
- attributes
Expand Down
187 changes: 91 additions & 96 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.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1540"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 1 addition & 5 deletions CodeEdit/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {

func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
let projects: [String] = CodeEditDocumentController.shared.documents
.map { doc in
(doc as? WorkspaceDocument)?.fileURL?.path
}
.filter { $0 != nil }
.map { $0! }
.compactMap { ($0 as? WorkspaceDocument)?.fileURL?.path }

UserDefaults.standard.set(projects, forKey: AppDelegate.recoverWorkspacesKey)

Expand Down
3 changes: 0 additions & 3 deletions CodeEdit/CodeEditApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ struct CodeEditApp: App {
@NSApplicationDelegateAdaptor var appdelegate: AppDelegate
@ObservedObject var settings = Settings.shared

@Environment(\.openWindow)
var openWindow

let updater: SoftwareUpdater = SoftwareUpdater()

init() {
Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/Features/CodeEditUI/Views/EffectView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// BlurView.swift
// EffectView.swift
// CodeEditModules/CodeEditUI
//
// Created by Rehatbir Singh on 15/03/2022.
Expand Down
1 change: 0 additions & 1 deletion CodeEdit/Features/CodeEditUI/Views/KeyValueTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ private struct NewListTableItemView: View {
.disabled(key.isEmpty || value.isEmpty)
}
.padding(.horizontal, 20)
// .padding(.top, 2)
.padding(.bottom, 20)
}
.frame(maxWidth: 480)
Expand Down
1 change: 0 additions & 1 deletion CodeEdit/Features/CodeEditUI/Views/PaneTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import SwiftUI
import Combine
import Introspect

struct PaneTextField<LeadingAccessories: View, TrailingAccessories: View>: View {
@Environment(\.colorScheme)
Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/Features/CodeEditUI/Views/SearchPanel.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// OverlayPanel.swift
// SearchPanel.swift
// CodeEditModules/CodeEditUI
//
// Created by Pavel Kasila on 20.03.22.
Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/Features/CodeEditUI/Views/SearchPanelView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// OverlayWindow.swift
// SearchPanelView.swift
// CodeEdit
//
// Created by Khan Winter on 3/17/23.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct XcodeButtonStyle: ButtonStyle {
return (3, 8)
case .large:
return (6, 12)
@unknown default:
default:
return (4, 8)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ final class QuickActionsViewModel: ObservableObject {
}
self.filteredCommands = CommandManager.shared.commands.filter { $0.title.localizedCaseInsensitiveContains(val) }
self.selected = self.filteredCommands.first

}
}
2 changes: 1 addition & 1 deletion CodeEdit/Features/Documents/CodeFileDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ final class CodeFileDocument: NSDocument, ObservableObject {

// MARK: - NSDocument

override class var autosavesInPlace: Bool {
override static var autosavesInPlace: Bool {
Settings.shared.preferences.general.isAutoSaveOn
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ final class CodeEditDocumentController: NSDocumentController {
@Environment(\.openWindow)
private var openWindow

lazy var fileManager: FileManager = {
FileManager.default
}()
private let fileManager = FileManager.default

override func newDocument(_ sender: Any?) {
guard let newDocumentUrl = self.newDocumentUrl else { return }
Expand Down
17 changes: 5 additions & 12 deletions CodeEdit/Features/Documents/LazyStringLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,13 @@ class LazyStringLoader {
if fileHandle == nil {
do {
fileHandle = try FileHandle(forReadingFrom: fileURL)
guard let data = try fileHandle?.read(upToCount: chunkSize) else {
return nil
}
return String(decoding: data, as: UTF8.self)
} catch {

}

var data = Data()
let semaphore = DispatchSemaphore(value: 0)

do {
data = try fileHandle?.read(upToCount: chunkSize) ?? Data()
} catch {

return nil
}

return String(data: data, encoding: .utf8)
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions CodeEdit/Features/Documents/WorkspaceDocument+Find.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ extension WorkspaceDocument.SearchState {
/// await evaluateFile(query: "example", searchResult: &resultModel)
/// ```
private func evaluateFile(query: String, searchResult: inout SearchResultModel) async {
guard let data = try? Data(contentsOf: searchResult.file.url),
let fileContent = String(data: data, encoding: .utf8) else {
guard let data = try? Data(contentsOf: searchResult.file.url) else {
return
}
let fileContent = String(decoding: data, as: UTF8.self)

// Attempt to create a regular expression from the provided query
guard let regex = try? NSRegularExpression(
Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/Features/Documents/WorkspaceDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class WorkspaceDocument: NSDocument, ObservableObject, NSToolbarDelegate {
".DS_Store"
]

override class var autosavesInPlace: Bool {
override static var autosavesInPlace: Bool {
false
}

Expand Down
3 changes: 0 additions & 3 deletions CodeEdit/Features/Editor/Models/EditorManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Combine
import Foundation
import DequeModule
import OrderedCollections
import os

class EditorManager: ObservableObject {
Expand All @@ -30,8 +29,6 @@ class EditorManager: ObservableObject {
/// History of last-used editors.
var activeEditorHistory: Deque<() -> Editor?> = []

var fileDocuments: [CEWorkspaceFile: CodeFileDocument] = [:]

/// notify listeners whenever tab selection changes on the active editor.
var tabBarTabIdSubject = PassthroughSubject<String?, Never>()
var cancellable: AnyCancellable?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ final class PathBarMenuItem: NSMenuItem {
self.fileItem = fileItem
self.tappedOpenFile = tappedOpenFile
super.init(title: fileItem.name, action: #selector(openFile), keyEquivalent: "")

let icon = fileItem.systemImage
var color = NSColor(fileItem.iconColor)
isEnabled = true
target = self
Expand Down
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 Down
13 changes: 6 additions & 7 deletions CodeEdit/Features/Extensions/ExtensionSceneView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,25 @@ struct ExtensionSceneView: NSViewControllerRepresentable {
var connection: NSXPCConnection?

func publishEnvironment(data: Data) {
@Decoded<Callbacks> var data = data
guard let $data else { return }
switch $data {
guard let decodedCallbacks = try? JSONDecoder().decode(Callbacks.self, from: data) else { return }
switch decodedCallbacks {
case .openWindow(let id):
openWindow(id)
}
}

func updateEnvironment(@Encoded _ value: _CEEnvironment) {
guard let $value else { return }
func updateEnvironment(_ value: _CEEnvironment) {
guard let newEnvironmentData = try? JSONEncoder().encode(value) else { return }

guard isOnline else {
toPublish = $value
toPublish = newEnvironmentData
return
}

Task {
do {
try await connection!.withService { (service: EnvironmentPublisherObjc) in
service.publishEnvironment(data: $value)
service.publishEnvironment(data: newEnvironmentData)
}
} catch {
print(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ struct GitHubOAuthConfiguration: GitRouterConfiguration {
if response.statusCode != 200 {
return
} else {
if let data, let string = String(data: data, encoding: .utf8) {
if let data {
let string = String(decoding: data, as: UTF8.self)
let accessToken = self.accessTokenFromResponse(string)
if let accessToken {
let config = GitHubTokenConfiguration(accessToken, url: self.apiEndpoint ?? "")
Expand Down
16 changes: 6 additions & 10 deletions CodeEdit/Features/Git/Accounts/Networking/GitJSONPostRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ extension GitJSONPostRouter {
with: data,
options: .mutableContainers
) as? [String: Any] {

userInfo[gitErrorKey] = json as Any?

} else if let data,
let string = String(data: data, encoding: .utf8) {
// swiftlint:disable:next non_optional_string_data_conversion
} else if let data, let string = String(data: data, encoding: .utf8) {
userInfo[gitErrorKey] = string as Any?
}

Expand Down Expand Up @@ -125,10 +123,9 @@ extension GitJSONPostRouter {
with: responseTuple.0,
options: .mutableContainers
) as? [String: Any] {

userInfo[gitErrorKey] = json as Any?

} else if let string = String(data: responseTuple.0, encoding: String.Encoding.utf8) {
// swiftlint:disable:next non_optional_string_data_conversion
} else if let string = String(data: responseTuple.0, encoding: .utf8) {
userInfo[gitErrorKey] = string as Any?
}
throw NSError(domain: configuration?.errorDomain ?? "", code: response.statusCode, userInfo: userInfo)
Expand Down Expand Up @@ -165,9 +162,8 @@ extension GitJSONPostRouter {
with: data,
options: .mutableContainers
) as? [String: Any] {

userInfo[gitErrorKey] = json as Any?

// swiftlint:disable:next non_optional_string_data_conversion
} else if let data, let string = String(data: data, encoding: String.Encoding.utf8) {
userInfo[gitErrorKey] = string as Any?
}
Expand Down Expand Up @@ -219,8 +215,8 @@ extension GitJSONPostRouter {
with: responseTuple.0,
options: .mutableContainers
) as? [String: Any] {

userInfo[gitErrorKey] = json as Any?
// swiftlint:disable:next non_optional_string_data_conversion
} else if let string = String(data: responseTuple.0, encoding: String.Encoding.utf8) {
userInfo[gitErrorKey] = string as Any?
}
Expand Down
4 changes: 2 additions & 2 deletions CodeEdit/Features/Git/SourceControlManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ final class SourceControlManager: ObservableObject {
}

/// Apply stash entry
func applyStashEntry(stashEntry: GitStashEntry?) async throws {
try await gitClient.applyStashEntry(stashEntry?.index)
func applyStashEntry(stashEntry: GitStashEntry) async throws {
try await gitClient.applyStashEntry(stashEntry.index)
try await refreshStashEntries()
await refreshAllChangedFiles()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct SourceControlNavigatorRepositoryView: View {
Button("Apply") {
if let stashEntry = stashEntryToApply {
Task {
try await sourceControlManager.applyStashEntry(stashEntry: stashEntryToApply)
try await sourceControlManager.applyStashEntry(stashEntry: stashEntry)
applyStashedChangesIsPresented = false
stashEntryToApply = nil
}
Expand Down
4 changes: 2 additions & 2 deletions CodeEdit/Features/QuickOpen/Views/NSTableViewWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ struct NSTableViewWrapper<Content: View, Item: Identifiable & Hashable>: NSViewR
}
}

func makeCoordinator() -> Coordinator<Content> {
func makeCoordinator() -> Coordinator {
Coordinator(parent: self)
}

class Coordinator<Content: View>: NSObject, NSTableViewDelegate, NSTableViewDataSource {
class Coordinator: NSObject, NSTableViewDelegate, NSTableViewDataSource {

var parent: NSTableViewWrapper

Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/Features/Settings/Models/Settings.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// SettingsModel.swift
// Settings.swift
// CodeEditModules/Settings
//
// Created by Lukas Pistrol on 01.04.22.
Expand Down
1 change: 0 additions & 1 deletion CodeEdit/Features/Settings/Models/SettingsSidebarFix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Created by Wouter Hennen on 13/04/2023.
//

import Foundation
import AppKit

extension NSSplitViewItem {
Expand Down
Loading