Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ opt_in_rules:
- modifier_order
- convenience_type
- pattern_matching_keywords
- multiline_parameters_brackets
- multiline_arguments_brackets

custom_rules:
spaces_over_tabs:
Expand Down
31 changes: 19 additions & 12 deletions CodeEdit/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class CodeEditApplication: NSApplication {
}

@NSApplicationMain
final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject { // swiftlint:disable:this type_body_length
var updater: SoftwareUpdater = SoftwareUpdater()

func applicationWillFinishLaunching(_ notification: Notification) {
Expand All @@ -44,9 +44,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
!projects.isEmpty {
projects.forEach { path in
let url = URL(fileURLWithPath: path)
CodeEditDocumentController.shared.reopenDocument(for: url,
withContentsOf: url,
display: true) { document, _, _ in
CodeEditDocumentController.shared.reopenDocument(
for: url,
withContentsOf: url,
display: true
) { document, _, _ in
document?.windowControllers.first?.synchronizeWindowTitleWithDocumentName()
}
}
Expand All @@ -60,9 +62,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
let path = CommandLine.arguments[index+1]
let url = URL(fileURLWithPath: path)

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

Expand Down Expand Up @@ -215,9 +219,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
CodeEditDocumentController.shared.reopenDocument(
for: fileURL,
withContentsOf: fileURL,
display: true) { document, _, _ in
document?.windowControllers.first?.synchronizeWindowTitleWithDocumentName()
}
display: true
) { document, _, _ in
document?.windowControllers.first?.synchronizeWindowTitleWithDocumentName()
}
}

defaults.removeObject(forKey: "openInCEFiles")
Expand Down Expand Up @@ -256,8 +261,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
Preferences.Pane(
identifier: Preferences.PaneIdentifier("Navigation"),
title: "Navigation",
toolbarIcon: NSImage(systemSymbolName: "arrow.triangle.turn.up.right.diamond",
accessibilityDescription: nil)!
toolbarIcon: NSImage(
systemSymbolName: "arrow.triangle.turn.up.right.diamond",
accessibilityDescription: nil
)!
) {
PreferencesPlaceholderView()
},
Expand Down
7 changes: 4 additions & 3 deletions CodeEdit/Features/About/Views/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ public struct AboutView: View {
}

public func showWindow(width: CGFloat, height: CGFloat) {
AboutViewWindowController(view: self,
size: NSSize(width: width,
height: height))
AboutViewWindowController(
view: self,
size: NSSize(width: width, height: height)
)
.showWindow(nil)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ extension AppPreferences {
/// Explicit decoder init for setting default values when key is not present in `JSON`
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.sourceControlAccounts = try container.decodeIfPresent(GitAccounts.self,
forKey: .sourceControlAccounts) ?? .init()
self.sourceControlAccounts = try container.decodeIfPresent(
GitAccounts.self,
forKey: .sourceControlAccounts
) ?? .init()
}
}

Expand Down
6 changes: 4 additions & 2 deletions CodeEdit/Features/AppPreferences/Model/AppPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ struct AppPreferences: Codable {
self.theme = try container.decodeIfPresent(ThemePreferences.self, forKey: .theme) ?? .init()
self.terminal = try container.decodeIfPresent(TerminalPreferences.self, forKey: .terminal) ?? .init()
self.textEditing = try container.decodeIfPresent(TextEditingPreferences.self, forKey: .textEditing) ?? .init()
self.sourceControl = try container.decodeIfPresent(SourceControlPreferences.self,
forKey: .sourceControl) ?? .init()
self.sourceControl = try container.decodeIfPresent(
SourceControlPreferences.self,
forKey: .sourceControl
) ?? .init()
self.keybindings = try container.decodeIfPresent(KeybindingsPreferences.self, forKey: .keybindings) ?? .init()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@ extension AppPreferences {
/// Explicit decoder init for setting default values when key is not present in `JSON`
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.keybindings = try container.decodeIfPresent([String: KeyboardShortcutWrapper].self,
forKey: .keybindings) ?? .init()
self.keybindings = try container.decodeIfPresent(
[String: KeyboardShortcutWrapper].self,
forKey: .keybindings
) ?? .init()
appendNew()

let mgr = CommandManager.shared
let wrap = CommandClosureWrapper.init(closure: {
print("testing closure")
})
mgr.addCommand(name: "Send test to console",
title: "Send test to console", id: "codeedit.test", command: wrap)
mgr.addCommand(
name: "Send test to console",
title: "Send test to console", id: "codeedit.test", command: wrap
)
mgr.executeCommand(name: "test")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,35 @@ extension AppPreferences {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.enableSourceControl = try container.decodeIfPresent(Bool.self, forKey: .enableSourceControl) ?? true
self.refreshStatusLocaly = try container.decodeIfPresent(Bool.self, forKey: .refreshStatusLocaly) ?? true
self.fetchRefreshServerStatus = try container.decodeIfPresent(Bool.self,
forKey: .fetchRefreshServerStatus) ?? true
self.addRemoveAutomatically = try container.decodeIfPresent(Bool.self,
forKey: .addRemoveAutomatically) ?? true
self.fetchRefreshServerStatus = try container.decodeIfPresent(
Bool.self,
forKey: .fetchRefreshServerStatus
) ?? true
self.addRemoveAutomatically = try container.decodeIfPresent(
Bool.self,
forKey: .addRemoveAutomatically
) ?? true
self.selectFilesToCommit = try container.decodeIfPresent(Bool.self, forKey: .selectFilesToCommit) ?? true
self.showSourceControlChanges = try container.decodeIfPresent(Bool.self,
forKey: .showSourceControlChanges) ?? true
self.includeUpstreamChanges = try container.decodeIfPresent(Bool.self,
forKey: .includeUpstreamChanges) ?? true
self.openFeedbackInBrowser = try container.decodeIfPresent(Bool.self,
forKey: .openFeedbackInBrowser) ?? true
self.revisionComparisonLayout = try container.decodeIfPresent(RevisionComparisonLayout.self,
forKey: .revisionComparisonLayout) ?? .localLeft
self.controlNavigatorOrder = try container.decodeIfPresent(ControlNavigatorOrder.self,
forKey: .controlNavigatorOrder) ?? .sortByName
self.showSourceControlChanges = try container.decodeIfPresent(
Bool.self,
forKey: .showSourceControlChanges
) ?? true
self.includeUpstreamChanges = try container.decodeIfPresent(
Bool.self,
forKey: .includeUpstreamChanges
) ?? true
self.openFeedbackInBrowser = try container.decodeIfPresent(
Bool.self,
forKey: .openFeedbackInBrowser
) ?? true
self.revisionComparisonLayout = try container.decodeIfPresent(
RevisionComparisonLayout.self,
forKey: .revisionComparisonLayout
) ?? .localLeft
self.controlNavigatorOrder = try container.decodeIfPresent(
ControlNavigatorOrder.self,
forKey: .controlNavigatorOrder
) ?? .sortByName
self.defaultBranchName = try container.decodeIfPresent(String.self, forKey: .defaultBranchName) ?? "main"
}
}
Expand Down Expand Up @@ -107,12 +121,18 @@ extension AppPreferences {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.authorName = try container.decodeIfPresent(String.self, forKey: .authorName) ?? ""
self.authorEmail = try container.decodeIfPresent(String.self, forKey: .authorEmail) ?? ""
self.ignoredFiles = try container.decodeIfPresent([IgnoredFiles].self,
forKey: .ignoredFiles) ?? []
self.preferRebaseWhenPulling = try container.decodeIfPresent(Bool.self,
forKey: .preferRebaseWhenPulling) ?? false
self.showMergeCommitsPerFileLog = try container.decodeIfPresent(Bool.self,
forKey: .showMergeCommitsPerFileLog) ?? false
self.ignoredFiles = try container.decodeIfPresent(
[IgnoredFiles].self,
forKey: .ignoredFiles
) ?? []
self.preferRebaseWhenPulling = try container.decodeIfPresent(
Bool.self,
forKey: .preferRebaseWhenPulling
) ?? false
self.showMergeCommitsPerFileLog = try container.decodeIfPresent(
Bool.self,
forKey: .showMergeCommitsPerFileLog
) ?? false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,21 @@ extension AppPreferences {
self.defaultTabWidth = try container.decodeIfPresent(Int.self, forKey: .defaultTabWidth) ?? 4
self.font = try container.decodeIfPresent(EditorFont.self, forKey: .font) ?? .init()
self.enableTypeOverCompletion = try container.decodeIfPresent(
Bool.self, forKey: .enableTypeOverCompletion) ?? true
self.autocompleteBraces = try container.decodeIfPresent(Bool.self,
forKey: .autocompleteBraces) ?? true
self.wrapLinesToEditorWidth = try container.decodeIfPresent(Bool.self,
forKey: .wrapLinesToEditorWidth) ?? true
self.lineHeightMultiple = try container.decodeIfPresent(Double.self,
forKey: .lineHeightMultiple) ?? 1.45
Bool.self,
forKey: .enableTypeOverCompletion
) ?? true
self.autocompleteBraces = try container.decodeIfPresent(
Bool.self,
forKey: .autocompleteBraces
) ?? true
self.wrapLinesToEditorWidth = try container.decodeIfPresent(
Bool.self,
forKey: .wrapLinesToEditorWidth
) ?? true
self.lineHeightMultiple = try container.decodeIfPresent(
Double.self,
forKey: .lineHeightMultiple
) ?? 1.45

self.populateCommands()
}
Expand All @@ -62,23 +70,26 @@ extension AppPreferences {
id: "prefs.text_editing.type_over_completion",
command: CommandClosureWrapper {
AppPreferencesModel.shared.preferences.textEditing.enableTypeOverCompletion.toggle()
})
}
)

mgr.addCommand(
name: "Toggle Autocomplete Braces",
title: "Toggle Autocomplete Braces",
id: "prefs.text_editing.autocomplete_braces",
command: CommandClosureWrapper {
AppPreferencesModel.shared.preferences.textEditing.autocompleteBraces.toggle()
})
}
)

mgr.addCommand(
name: "Toggle Word Wrap",
title: "Toggle Word Wrap",
id: "prefs.text_editing.wrap_lines_to_editor_width",
command: CommandClosureWrapper {
AppPreferencesModel.shared.preferences.textEditing.wrapLinesToEditorWidth.toggle()
})
}
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ struct AccountPreferencesView: View {
.foregroundColor(.secondary)
.frame(maxWidth: .infinity, alignment: .leading)
}
List($prefs.preferences.accounts.sourceControlAccounts.gitAccount,
selection: $accountSelection) { gitAccount in
List(
$prefs.preferences.accounts.sourceControlAccounts.gitAccount,
selection: $accountSelection
) { gitAccount in
GitAccountItemView(sourceControlAccount: gitAccount)
}
.background(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ struct GitHubEnterpriseLoginView: View {
}
HStack {
Text("Token:")
SecureField("Enter your Personal Access Token",
text: $accountToken)
SecureField(
"Enter your Personal Access Token",
text: $accountToken
)
.frame(width: 300)
}
}
Expand Down Expand Up @@ -76,8 +78,10 @@ struct GitHubEnterpriseLoginView: View {
private func loginGitHubEnterprise(gitAccountName: String) {
let gitAccounts = prefs.preferences.accounts.sourceControlAccounts.gitAccount

let config = GitHubTokenConfiguration(accountToken,
url: eneterpriseLink )
let config = GitHubTokenConfiguration(
accountToken,
url: eneterpriseLink
)
GitHubAccount(config).me { response in
switch response {
case .success(let user):
Expand All @@ -86,14 +90,17 @@ struct GitHubEnterpriseLoginView: View {
} else {
print(user)
prefs.preferences.accounts.sourceControlAccounts.gitAccount.append(
SourceControlAccounts(id: gitAccountName.lowercased(),
gitProvider: "GitHub",
gitProviderLink: eneterpriseLink,
gitProviderDescription: "GitHub",
gitAccountName: gitAccountName,
gitCloningProtocol: true,
gitSSHKey: "",
isTokenValid: true))
SourceControlAccounts(
id: gitAccountName.lowercased(),
gitProvider: "GitHub",
gitProviderLink: eneterpriseLink,
gitProviderDescription: "GitHub",
gitAccountName: gitAccountName,
gitCloningProtocol: true,
gitSSHKey: "",
isTokenValid: true
)
)
keychain.set(accountToken, forKey: "github_\(accountName)_enterprise")
dismissDialog = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ struct GitHubLoginView: View {
}
HStack {
Text("Token:")
SecureField("Enter your Personal Access Token",
text: $accountToken)
SecureField(
"Enter your Personal Access Token",
text: $accountToken
)
.frame(width: 300)
}
}
Expand Down Expand Up @@ -111,14 +113,17 @@ struct GitHubLoginView: View {
} else {
print(user)
prefs.preferences.accounts.sourceControlAccounts.gitAccount.append(
SourceControlAccounts(id: gitAccountName.lowercased(),
gitProvider: "GitHub",
gitProviderLink: "https://github.com",
gitProviderDescription: "GitHub",
gitAccountName: gitAccountName,
gitCloningProtocol: true,
gitSSHKey: "",
isTokenValid: true))
SourceControlAccounts(
id: gitAccountName.lowercased(),
gitProvider: "GitHub",
gitProviderLink: "https://github.com",
gitProviderDescription: "GitHub",
gitAccountName: gitAccountName,
gitCloningProtocol: true,
gitSSHKey: "",
isTokenValid: true
)
)
keychain.set(accountToken, forKey: "github_\(accountName)")
dismissDialog.toggle()
}
Expand Down
Loading