From d1c8611ec109a3bc626c7213d8bd02589b39a40e Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Mon, 19 Jun 2023 20:38:03 +0200 Subject: [PATCH 1/7] SwiftLint enabled `attributes` rule --- .swiftlint.yml | 1 + CodeEdit/AppDelegate.swift | 3 +- .../About/Views/AboutDefaultView.swift | 4 +- .../About/Views/AboutDetailView.swift | 3 +- CodeEdit/Features/About/Views/AboutView.swift | 9 +- .../About/Views/BlurButtonStyle.swift | 6 +- .../AcknowledgementsViewModel.swift | 3 +- .../Views/AcknowledgementRowView.swift | 3 +- .../CodeEditUI/Views/AreaTabBar.swift | 3 +- .../CodeEditUI/Views/OverlayView.swift | 3 +- .../CodeEditUI/Views/SegmentedControl.swift | 12 +- .../Views/SegmentedControlImproved.swift | 9 +- .../CodeEditUI/Views/SettingsTextEditor.swift | 6 +- .../Views/ToolbarBranchPicker.swift | 15 +-- CodeEdit/Features/CodeFile/CodeFile.swift | 6 +- CodeEdit/Features/CodeFile/CodeFileView.swift | 50 ++++---- .../ViewModels/CommandPaletteViewModel.swift | 12 +- .../Commands/Views/CommandPaletteView.swift | 12 +- .../Contributors/ContributorRowView.swift | 3 +- .../Features/DebugArea/DebugAreaView.swift | 3 +- CodeEdit/Features/DebugArea/PaneToolbar.swift | 3 +- .../ViewModels/DebugAreaTabViewModel.swift | 12 +- .../ViewModels/DebugAreaViewModel.swift | 21 +-- .../DebugArea/Views/DebugAreaOutputView.swift | 15 +-- .../DebugArea/Views/DebugAreaTabView.swift | 3 +- .../Views/DebugAreaTerminalTab.swift | 6 +- .../Views/DebugAreaTerminalView.swift | 33 ++--- .../Views/Toolbar/FilterTextField.swift | 6 +- .../Views/Toolbar/StatusBarClearButton.swift | 3 +- .../Toolbar/StatusBarMaximizeButton.swift | 3 +- .../StatusBarSplitTerminalButton.swift | 3 +- .../Views/WorkspaceCodeFileView.swift | 9 +- .../WorkspaceDocument+Listeners.swift | 3 +- .../Documents/WorkspaceDocument.swift | 6 +- .../Extensions/ExtensionSceneView.swift | 3 +- CodeEdit/Features/Feedback/FeedbackView.swift | 9 +- .../Feedback/Model/FeedbackModel.swift | 68 +++++----- .../InspectorSidebarToolbarTop.swift | 4 +- .../InspectorSidebarView.swift | 12 +- .../Models/FileInspectorModel.swift | 120 +++++++----------- .../Models/HistoryInspectorModel.swift | 3 +- .../Views/FileInspectorView.swift | 3 +- .../Views/HistoryInspectorItemView.swift | 3 +- .../Views/HistoryInspectorView.swift | 3 +- .../Views/Popover/HistoryPopoverView.swift | 6 +- .../FindNavigatorModeSelector.swift | 6 +- .../FindNavigatorResultFileItem.swift | 10 +- .../FindNavigatorResultList.swift | 6 +- .../FindNavigatorSearchBar.swift | 9 +- .../FindNavigator/FindNavigatorView.swift | 12 +- .../NavigatorSidebarToolbar.swift | 3 +- .../NavigatorSidebarView.swift | 9 +- .../ProjectNavigatorOutlineView.swift | 6 +- .../ProjectNavigatorToolbarBottom.swift | 6 +- .../Model/SourceControlModel.swift | 3 +- .../SourceControlNavigatorView.swift | 6 +- .../SourceControlSearchToolbar.swift | 3 +- ...ourceControlNavigatorChangedFileView.swift | 9 +- .../SourceControlNavigatorChangesView.swift | 6 +- .../PathBar/Views/PathBarComponent.swift | 9 +- .../Features/PathBar/Views/PathBarMenu.swift | 3 +- .../ViewModels/QuickOpenViewModel.swift | 9 +- .../Views/QuickOpenPreviewView.swift | 3 +- .../QuickOpen/Views/QuickOpenView.swift | 6 +- .../Features/Settings/Models/Settings.swift | 3 +- .../Settings/Models/SettingsSidebarFix.swift | 4 +- .../AccountSelectionView.swift | 3 +- .../AccountsSettingsDetailsView.swift | 9 +- .../AccountsSettingsSigninView.swift | 9 +- .../AccountsSettingsView.swift | 3 +- .../AccountsSettings/CreateSSHKeyView.swift | 3 +- .../GeneralSettings/GeneralSettingsView.swift | 3 +- .../LocationsSettingsView.swift | 3 +- .../SourceControlGeneralView.swift | 6 +- .../SourceControlGitView.swift | 6 +- .../TerminalSettingsView.swift | 9 +- .../TextEditingSettingsView.swift | 33 ++--- .../ThemeSettings/Models/ThemeModel.swift | 18 +-- .../ThemeSettingsColorPreview.swift | 3 +- .../ThemeSettingsThemeDetails.swift | 6 +- .../ThemeSettings/ThemeSettingsView.swift | 9 +- CodeEdit/Features/Settings/SettingsView.swift | 6 +- .../Features/Settings/SoftwareUpdater.swift | 9 +- .../Settings/Views/SettingsForm.swift | 6 +- .../View+NavigationBarBackButtonVisible.swift | 3 +- CodeEdit/Features/SplitView/EditorView.swift | 3 +- .../StatusBar/Views/StatusBarIcon.swift | 6 +- .../StatusBarBreakpointButton.swift | 3 +- .../StatusBarCursorLocationLabel.swift | 3 +- .../StatusBarIndentSelector.swift | 3 +- .../StatusBarToggleDrawerButton.swift | 3 +- .../StatusBar/Views/StatusBarView.swift | 3 +- .../Features/Tabs/Models/TabManager.swift | 6 +- .../Features/Tabs/TabGroup/TabGroupData.swift | 15 +-- .../Tabs/TabGroup/WorkspaceTabGroupView.swift | 9 +- .../Tabs/Views/TabBarContextMenu.swift | 9 +- .../Features/Tabs/Views/TabBarDivider.swift | 9 +- .../Tabs/Views/TabBarItemButtonStyle.swift | 3 +- .../Tabs/Views/TabBarItemCloseButton.swift | 12 +- .../Features/Tabs/Views/TabBarItemView.swift | 33 ++--- CodeEdit/Features/Tabs/Views/TabBarView.swift | 69 ++++------ .../TerminalEmulatorView+Coordinator.swift | 3 +- .../TerminalEmulatorView.swift | 12 +- .../Features/Welcome/Views/WelcomeView.swift | 18 +-- .../Welcome/Views/WelcomeWindow.swift | 6 +- .../WindowCommands/ExtensionCommands.swift | 3 +- .../WindowCommands/MainCommands.swift | 4 +- .../WindowCommands/ViewCommands.swift | 6 +- .../WindowCommands/WindowCommands.swift | 3 +- CodeEdit/WindowObserver.swift | 9 +- CodeEdit/WorkspaceView.swift | 27 ++-- OpenWithCodeEdit/FinderSync.swift | 3 +- 112 files changed, 460 insertions(+), 627 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 1f931e7c7..c0d87c6e0 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -17,6 +17,7 @@ excluded: - CodeEditModules/.build # Where Swift Package Manager checks out dependency sources - DerivedData opt_in_rules: + - attributes - empty_count - closure_spacing - contains_over_first_not_nil diff --git a/CodeEdit/AppDelegate.swift b/CodeEdit/AppDelegate.swift index db73120ce..407a62c38 100644 --- a/CodeEdit/AppDelegate.swift +++ b/CodeEdit/AppDelegate.swift @@ -207,7 +207,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject { // MARK: NSDocumentController delegate - @objc func documentController(_ docController: NSDocumentController, didCloseAll: Bool, contextInfo: Any) { + @objc + func documentController(_ docController: NSDocumentController, didCloseAll: Bool, contextInfo: Any) { NSApplication.shared.reply(toApplicationShouldTerminate: didCloseAll) } } diff --git a/CodeEdit/Features/About/Views/AboutDefaultView.swift b/CodeEdit/Features/About/Views/AboutDefaultView.swift index 99038b917..62312c51f 100644 --- a/CodeEdit/Features/About/Views/AboutDefaultView.swift +++ b/CodeEdit/Features/About/Views/AboutDefaultView.swift @@ -22,7 +22,9 @@ struct AboutDefaultView: View { @Binding var aboutMode: AboutMode var namespace: Namespace.ID - @Environment(\.colorScheme) var colorScheme + + @Environment(\.colorScheme) + var colorScheme private static var licenseURL = URL(string: "https://github.com/CodeEditApp/CodeEdit/blob/main/LICENSE.md")! diff --git a/CodeEdit/Features/About/Views/AboutDetailView.swift b/CodeEdit/Features/About/Views/AboutDetailView.swift index c287dfa67..9e365982a 100644 --- a/CodeEdit/Features/About/Views/AboutDetailView.swift +++ b/CodeEdit/Features/About/Views/AboutDetailView.swift @@ -14,8 +14,7 @@ struct AboutDetailView: View { var namespace: Namespace.ID - @ViewBuilder - var content: Content + @ViewBuilder var content: Content let smallTitlebarHeight: CGFloat = 28 let mediumTitlebarHeight: CGFloat = 113 diff --git a/CodeEdit/Features/About/Views/AboutView.swift b/CodeEdit/Features/About/Views/AboutView.swift index 4644d0d43..900177edb 100644 --- a/CodeEdit/Features/About/Views/AboutView.swift +++ b/CodeEdit/Features/About/Views/AboutView.swift @@ -14,9 +14,12 @@ enum AboutMode: String, CaseIterable { } public struct AboutView: View { - @Environment(\.openURL) private var openURL - @Environment(\.colorScheme) private var colorScheme - @Environment(\.dismiss) private var dismiss + @Environment(\.openURL) + private var openURL + @Environment(\.colorScheme) + private var colorScheme + @Environment(\.dismiss) + private var dismiss @State var aboutMode: AboutMode = .about diff --git a/CodeEdit/Features/About/Views/BlurButtonStyle.swift b/CodeEdit/Features/About/Views/BlurButtonStyle.swift index 49425c77b..1ec9cc5ca 100644 --- a/CodeEdit/Features/About/Views/BlurButtonStyle.swift +++ b/CodeEdit/Features/About/Views/BlurButtonStyle.swift @@ -12,7 +12,8 @@ extension ButtonStyle where Self == BlurButtonStyle { } struct BlurButtonStyle: ButtonStyle { - @Environment(\.controlSize) var controlSize + @Environment(\.controlSize) + var controlSize var height: CGFloat { switch controlSize { @@ -23,7 +24,8 @@ struct BlurButtonStyle: ButtonStyle { } } - @Environment(\.colorScheme) var colorScheme + @Environment(\.colorScheme) + var colorScheme func makeBody(configuration: Configuration) -> some View { configuration.label diff --git a/CodeEdit/Features/Acknowledgements/ViewModels/AcknowledgementsViewModel.swift b/CodeEdit/Features/Acknowledgements/ViewModels/AcknowledgementsViewModel.swift index bafb6d8ae..ad2660055 100644 --- a/CodeEdit/Features/Acknowledgements/ViewModels/AcknowledgementsViewModel.swift +++ b/CodeEdit/Features/Acknowledgements/ViewModels/AcknowledgementsViewModel.swift @@ -9,8 +9,7 @@ import SwiftUI final class AcknowledgementsViewModel: ObservableObject { - @Published - private (set) var acknowledgements: [AcknowledgementDependency] + @Published private (set) var acknowledgements: [AcknowledgementDependency] var indexedAcknowledgements: [(index: Int, acknowledgement: AcknowledgementDependency)] { return Array(zip(acknowledgements.indices, acknowledgements)) diff --git a/CodeEdit/Features/Acknowledgements/Views/AcknowledgementRowView.swift b/CodeEdit/Features/Acknowledgements/Views/AcknowledgementRowView.swift index 2b639146d..bbb933826 100644 --- a/CodeEdit/Features/Acknowledgements/Views/AcknowledgementRowView.swift +++ b/CodeEdit/Features/Acknowledgements/Views/AcknowledgementRowView.swift @@ -8,7 +8,8 @@ import SwiftUI struct AcknowledgementRowView: View { - @Environment(\.openURL) private var openURL + @Environment(\.openURL) + private var openURL let acknowledgement: AcknowledgementDependency diff --git a/CodeEdit/Features/CodeEditUI/Views/AreaTabBar.swift b/CodeEdit/Features/CodeEditUI/Views/AreaTabBar.swift index 26c30ffc1..79d0b84e4 100644 --- a/CodeEdit/Features/CodeEditUI/Views/AreaTabBar.swift +++ b/CodeEdit/Features/CodeEditUI/Views/AreaTabBar.swift @@ -13,7 +13,8 @@ protocol AreaTab: View, Identifiable, Hashable { } struct AreaTabBar: View { - @Environment(\.controlActiveState) private var activeState + @Environment(\.controlActiveState) + private var activeState var items: [Tab] diff --git a/CodeEdit/Features/CodeEditUI/Views/OverlayView.swift b/CodeEdit/Features/CodeEditUI/Views/OverlayView.swift index 60139a825..e3729d356 100644 --- a/CodeEdit/Features/CodeEditUI/Views/OverlayView.swift +++ b/CodeEdit/Features/CodeEditUI/Views/OverlayView.swift @@ -142,8 +142,7 @@ struct OverlayView some View { configuration.label diff --git a/CodeEdit/Features/CodeEditUI/Views/SettingsTextEditor.swift b/CodeEdit/Features/CodeEditUI/Views/SettingsTextEditor.swift index 80d10aa12..54328c2c8 100644 --- a/CodeEdit/Features/CodeEditUI/Views/SettingsTextEditor.swift +++ b/CodeEdit/Features/CodeEditUI/Views/SettingsTextEditor.swift @@ -9,11 +9,9 @@ import Foundation import SwiftUI struct SettingsTextEditor: View { - @State - private var isFocus: Bool = false + @State private var isFocus: Bool = false - @Binding - var text: String + @Binding var text: String init(text: Binding) { self._text = text diff --git a/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift b/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift index c41fc234d..3b15ccee3 100644 --- a/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift +++ b/CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift @@ -16,14 +16,11 @@ struct ToolbarBranchPicker: View { @Environment(\.controlActiveState) private var controlActive - @State - private var isHovering: Bool = false + @State private var isHovering: Bool = false - @State - private var displayPopover: Bool = false + @State private var displayPopover: Bool = false - @State - private var currentBranch: String? + @State private var currentBranch: String? /// Initializes the ``ToolbarBranchPicker`` with an instance of a `WorkspaceClient` /// - Parameter shellClient: An instance of the current `ShellClient` @@ -105,8 +102,7 @@ struct ToolbarBranchPicker: View { private struct PopoverView: View { var gitClient: GitClient? - @Binding - var currentBranch: String? + @Binding var currentBranch: String? var body: some View { VStack(alignment: .leading) { @@ -154,8 +150,7 @@ struct ToolbarBranchPicker: View { @Environment(\.dismiss) private var dismiss - @State - private var isHovering: Bool = false + @State private var isHovering: Bool = false var body: some View { Button { diff --git a/CodeEdit/Features/CodeFile/CodeFile.swift b/CodeEdit/Features/CodeFile/CodeFile.swift index 7a8d18c58..6934dfcc7 100644 --- a/CodeEdit/Features/CodeFile/CodeFile.swift +++ b/CodeEdit/Features/CodeFile/CodeFile.swift @@ -20,8 +20,7 @@ enum CodeFileError: Error { @objc(CodeFileDocument) final class CodeFileDocument: NSDocument, ObservableObject, QLPreviewItem { - @Published - var content = "" + @Published var content = "" /* This is the main type of the document. @@ -56,8 +55,7 @@ final class CodeFileDocument: NSDocument, ObservableObject, QLPreviewItem { fileURL } - @Published - var cursorPosition = (1, 1) + @Published var cursorPosition = (1, 1) // MARK: - NSDocument diff --git a/CodeEdit/Features/CodeFile/CodeFileView.swift b/CodeEdit/Features/CodeFile/CodeFileView.swift index 060d62e95..75b46ae77 100644 --- a/CodeEdit/Features/CodeFile/CodeFileView.swift +++ b/CodeEdit/Features/CodeFile/CodeFileView.swift @@ -13,24 +13,31 @@ import Combine /// CodeFileView is just a wrapper of the `CodeEditor` dependency struct CodeFileView: View { - @ObservedObject - private var codeFile: CodeFileDocument - - @AppSettings(\.textEditing.defaultTabWidth) var defaultTabWidth - @AppSettings(\.textEditing.indentOption) var settingsIndentOption - @AppSettings(\.textEditing.lineHeightMultiple) var lineHeightMultiple - @AppSettings(\.textEditing.wrapLinesToEditorWidth) var wrapLinesToEditorWidth - @AppSettings(\.textEditing.font) var settingsFont - @AppSettings(\.theme.useThemeBackground) var useThemeBackground - @AppSettings(\.theme.matchAppearance) var matchAppearance - @AppSettings(\.textEditing.letterSpacing) var letterSpacing - @AppSettings(\.textEditing.bracketHighlight) var bracketHighlight + @ObservedObject private var codeFile: CodeFileDocument + + @AppSettings(\.textEditing.defaultTabWidth) + var defaultTabWidth + @AppSettings(\.textEditing.indentOption) + var settingsIndentOption + @AppSettings(\.textEditing.lineHeightMultiple) + var lineHeightMultiple + @AppSettings(\.textEditing.wrapLinesToEditorWidth) + var wrapLinesToEditorWidth + @AppSettings(\.textEditing.font) + var settingsFont + @AppSettings(\.theme.useThemeBackground) + var useThemeBackground + @AppSettings(\.theme.matchAppearance) + var matchAppearance + @AppSettings(\.textEditing.letterSpacing) + var letterSpacing + @AppSettings(\.textEditing.bracketHighlight) + var bracketHighlight @Environment(\.colorScheme) private var colorScheme - @StateObject - private var themeModel: ThemeModel = .shared + @StateObject private var themeModel: ThemeModel = .shared private var cancellables = [AnyCancellable]() @@ -62,16 +69,13 @@ struct CodeFileView: View { .store(in: &cancellables) } - @State - private var selectedTheme = ThemeModel.shared.selectedTheme ?? ThemeModel.shared.themes.first! + @State private var selectedTheme = ThemeModel.shared.selectedTheme ?? ThemeModel.shared.themes.first! - @State - private var font: NSFont = { + @State private var font: NSFont = { return Settings[\.textEditing].font.current() }() - @State - private var bracketPairHighlight: BracketPairHighlight? = { + @State private var bracketPairHighlight: BracketPairHighlight? = { let theme = ThemeModel.shared.selectedTheme ?? ThemeModel.shared.themes.first! let color = Settings[\.textEditing].bracketHighlight.useCustomColor ? Settings[\.textEditing].bracketHighlight.color.nsColor @@ -89,8 +93,7 @@ struct CodeFileView: View { }() // Tab is a placeholder value, is overriden immediately in `init`. - @State - private var indentOption: IndentOption = { + @State private var indentOption: IndentOption = { switch Settings[\.textEditing].indentOption.indentType { case .tab: return .tab @@ -102,8 +105,7 @@ struct CodeFileView: View { @Environment(\.edgeInsets) private var edgeInsets - @EnvironmentObject - private var tabgroup: TabGroupData + @EnvironmentObject private var tabgroup: TabGroupData var body: some View { CodeEditTextView( diff --git a/CodeEdit/Features/Commands/ViewModels/CommandPaletteViewModel.swift b/CodeEdit/Features/Commands/ViewModels/CommandPaletteViewModel.swift index f0b0fafe0..1e11ba961 100644 --- a/CodeEdit/Features/Commands/ViewModels/CommandPaletteViewModel.swift +++ b/CodeEdit/Features/Commands/ViewModels/CommandPaletteViewModel.swift @@ -11,17 +11,13 @@ import Foundation /// query text and list of filtered commands final class CommandPaletteViewModel: ObservableObject { - @Published - var commandQuery: String = "" + @Published var commandQuery: String = "" - @Published - var selected: Command? + @Published var selected: Command? - @Published - var isShowingCommandsList: Bool = true + @Published var isShowingCommandsList: Bool = true - @Published - var filteredCommands: [Command] = [] + @Published var filteredCommands: [Command] = [] init() {} diff --git a/CodeEdit/Features/Commands/Views/CommandPaletteView.swift b/CodeEdit/Features/Commands/Views/CommandPaletteView.swift index 3ad6cc8d4..4a2478bd3 100644 --- a/CodeEdit/Features/Commands/Views/CommandPaletteView.swift +++ b/CodeEdit/Features/Commands/Views/CommandPaletteView.swift @@ -13,17 +13,13 @@ struct CommandPaletteView: View { @Environment(\.colorScheme) private var colorScheme: ColorScheme - @ObservedObject - private var state: CommandPaletteViewModel + @ObservedObject private var state: CommandPaletteViewModel - @ObservedObject - private var commandManager: CommandManager = .shared + @ObservedObject private var commandManager: CommandManager = .shared - @State - private var monitor: Any? + @State private var monitor: Any? - @State - private var selectedItem: Command? + @State private var selectedItem: Command? private let closePalette: () -> Void diff --git a/CodeEdit/Features/Contributors/ContributorRowView.swift b/CodeEdit/Features/Contributors/ContributorRowView.swift index 763734575..85c989439 100644 --- a/CodeEdit/Features/Contributors/ContributorRowView.swift +++ b/CodeEdit/Features/Contributors/ContributorRowView.swift @@ -66,7 +66,8 @@ struct ContributorRowView: View { } private struct ActionButton: View { - @Environment(\.openURL) private var openURL + @Environment(\.openURL) + private var openURL @State private var hovering = false let url: URL diff --git a/CodeEdit/Features/DebugArea/DebugAreaView.swift b/CodeEdit/Features/DebugArea/DebugAreaView.swift index 77197f493..be9c2f8e1 100644 --- a/CodeEdit/Features/DebugArea/DebugAreaView.swift +++ b/CodeEdit/Features/DebugArea/DebugAreaView.swift @@ -11,8 +11,7 @@ struct DebugAreaView: View { @Environment(\.colorScheme) private var colorScheme - @EnvironmentObject - private var model: DebugAreaViewModel + @EnvironmentObject private var model: DebugAreaViewModel @State var selection: DebugAreaTab? = .terminal diff --git a/CodeEdit/Features/DebugArea/PaneToolbar.swift b/CodeEdit/Features/DebugArea/PaneToolbar.swift index 7d2492768..31d82a369 100644 --- a/CodeEdit/Features/DebugArea/PaneToolbar.swift +++ b/CodeEdit/Features/DebugArea/PaneToolbar.swift @@ -10,7 +10,8 @@ import SwiftUI struct PaneToolbar: View { @ViewBuilder var content: Content @EnvironmentObject var model: DebugAreaTabViewModel - @Environment(\.paneArea) var paneArea: PaneArea? + @Environment(\.paneArea) + var paneArea: PaneArea? var body: some View { HStack(spacing: 5) { diff --git a/CodeEdit/Features/DebugArea/ViewModels/DebugAreaTabViewModel.swift b/CodeEdit/Features/DebugArea/ViewModels/DebugAreaTabViewModel.swift index 5d6c91f4d..2a16b52ba 100644 --- a/CodeEdit/Features/DebugArea/ViewModels/DebugAreaTabViewModel.swift +++ b/CodeEdit/Features/DebugArea/ViewModels/DebugAreaTabViewModel.swift @@ -8,17 +8,13 @@ import SwiftUI class DebugAreaTabViewModel: ObservableObject { - @Published - var leadingSidebarIsCollapsed: Bool = false + @Published var leadingSidebarIsCollapsed: Bool = false - @Published - var trailingSidebarIsCollapsed: Bool = false + @Published var trailingSidebarIsCollapsed: Bool = false - @Published - var hasLeadingSidebar: Bool = false + @Published var hasLeadingSidebar: Bool = false - @Published - var hasTrailingSidebar: Bool = false + @Published var hasTrailingSidebar: Bool = false public static let shared: DebugAreaTabViewModel = .init() } diff --git a/CodeEdit/Features/DebugArea/ViewModels/DebugAreaViewModel.swift b/CodeEdit/Features/DebugArea/ViewModels/DebugAreaViewModel.swift index e5085fb39..fa189cc7d 100644 --- a/CodeEdit/Features/DebugArea/ViewModels/DebugAreaViewModel.swift +++ b/CodeEdit/Features/DebugArea/ViewModels/DebugAreaViewModel.swift @@ -18,32 +18,25 @@ class DebugAreaViewModel: ObservableObject { = "\(String(describing: DebugAreaViewModel.self))-DebugAreaViewHeight" /// Returns the current location of the cursor in an editing view - @Published - var cursorLocation: CursorLocation = .init(line: 1, column: 1) // Implementation needed!! + @Published var cursorLocation: CursorLocation = .init(line: 1, column: 1) // Implementation needed!! /// Indicates whether debugger is collapse or not - @Published - var isCollapsed: Bool = false + @Published var isCollapsed: Bool = false /// Returns true when the drawer is visible - @Published - var isMaximized: Bool = false + @Published var isMaximized: Bool = false /// The current height of the drawer. Zero if hidden - @Published - var currentHeight: Double = 0 + @Published var currentHeight: Double = 0 /// Indicates whether the drawer is being resized or not - @Published - var isDragging: Bool = false + @Published var isDragging: Bool = false /// Indicates whether the breakpoint is enabled or not - @Published - var isBreakpointEnabled: Bool = true + @Published var isBreakpointEnabled: Bool = true /// Search value to filter in drawer - @Published - var searchText: String = "" + @Published var searchText: String = "" /// Returns the font for status bar items to use private(set) var toolbarFont: Font = .system(size: 11, weight: .medium) diff --git a/CodeEdit/Features/DebugArea/Views/DebugAreaOutputView.swift b/CodeEdit/Features/DebugArea/Views/DebugAreaOutputView.swift index 0e693b9fe..38119772d 100644 --- a/CodeEdit/Features/DebugArea/Views/DebugAreaOutputView.swift +++ b/CodeEdit/Features/DebugArea/Views/DebugAreaOutputView.swift @@ -9,20 +9,15 @@ import SwiftUI import LogStream struct DebugAreaOutputView: View { - @EnvironmentObject - private var model: DebugAreaViewModel + @EnvironmentObject private var model: DebugAreaViewModel - @ObservedObject - var extensionManager = ExtensionManager.shared + @ObservedObject var extensionManager = ExtensionManager.shared - @State - var output: [LogMessage] = [] + @State var output: [LogMessage] = [] - @State - private var filterText = "" + @State private var filterText = "" - @State - var selectedOutputSource: ExtensionInfo? + @State var selectedOutputSource: ExtensionInfo? var filteredOutput: [LogMessage] { output.filter { item in diff --git a/CodeEdit/Features/DebugArea/Views/DebugAreaTabView.swift b/CodeEdit/Features/DebugArea/Views/DebugAreaTabView.swift index 834c180d5..afff55661 100644 --- a/CodeEdit/Features/DebugArea/Views/DebugAreaTabView.swift +++ b/CodeEdit/Features/DebugArea/Views/DebugAreaTabView.swift @@ -8,8 +8,7 @@ import SwiftUI struct DebugAreaTabView: View { - @ObservedObject - var model: DebugAreaTabViewModel = DebugAreaTabViewModel.shared + @ObservedObject var model: DebugAreaTabViewModel = DebugAreaTabViewModel.shared let content: (DebugAreaTabViewModel) -> Content let leadingSidebar: (DebugAreaTabViewModel) -> LeadingSidebar? diff --git a/CodeEdit/Features/DebugArea/Views/DebugAreaTerminalTab.swift b/CodeEdit/Features/DebugArea/Views/DebugAreaTerminalTab.swift index e27929a91..1ed52b7e9 100644 --- a/CodeEdit/Features/DebugArea/Views/DebugAreaTerminalTab.swift +++ b/CodeEdit/Features/DebugArea/Views/DebugAreaTerminalTab.swift @@ -8,8 +8,7 @@ import SwiftUI struct DebugAreaTerminalTab: View { - @Binding - var terminal: DebugAreaTerminal + @Binding var terminal: DebugAreaTerminal var removeTerminals: (_ ids: Set) -> Void @@ -17,8 +16,7 @@ struct DebugAreaTerminalTab: View { var selectedIDs: Set - @FocusState - private var isFocused: Bool + @FocusState private var isFocused: Bool var body: some View { var terminalTitle = Binding( diff --git a/CodeEdit/Features/DebugArea/Views/DebugAreaTerminalView.swift b/CodeEdit/Features/DebugArea/Views/DebugAreaTerminalView.swift index 4654f63b7..a1e08a231 100644 --- a/CodeEdit/Features/DebugArea/Views/DebugAreaTerminalView.swift +++ b/CodeEdit/Features/DebugArea/Views/DebugAreaTerminalView.swift @@ -26,36 +26,31 @@ struct DebugAreaTerminal: Identifiable, Equatable { } struct DebugAreaTerminalView: View { - @AppSettings(\.theme.matchAppearance) private var matchAppearance - @AppSettings(\.terminal.darkAppearance) private var darkAppearance - @AppSettings(\.theme.useThemeBackground) private var useThemeBackground + @AppSettings(\.theme.matchAppearance) + private var matchAppearance + @AppSettings(\.terminal.darkAppearance) + private var darkAppearance + @AppSettings(\.theme.useThemeBackground) + private var useThemeBackground @Environment(\.colorScheme) private var colorScheme - @EnvironmentObject - private var workspace: WorkspaceDocument + @EnvironmentObject private var workspace: WorkspaceDocument - @EnvironmentObject - private var model: DebugAreaViewModel + @EnvironmentObject private var model: DebugAreaViewModel - @State - private var sidebarIsCollapsed = false + @State private var sidebarIsCollapsed = false - @StateObject - private var themeModel: ThemeModel = .shared + @StateObject private var themeModel: ThemeModel = .shared - @State - var terminals: [DebugAreaTerminal] = [] + @State var terminals: [DebugAreaTerminal] = [] - @State - private var selectedIDs: Set = [UUID()] + @State private var selectedIDs: Set = [UUID()] - @State - private var isMenuVisible = false + @State private var isMenuVisible = false - @State - private var popoverSource: CGRect = .zero + @State private var popoverSource: CGRect = .zero private func initializeTerminals() { let id = UUID() diff --git a/CodeEdit/Features/DebugArea/Views/Toolbar/FilterTextField.swift b/CodeEdit/Features/DebugArea/Views/Toolbar/FilterTextField.swift index 2b4e9d2c7..20de5db6f 100644 --- a/CodeEdit/Features/DebugArea/Views/Toolbar/FilterTextField.swift +++ b/CodeEdit/Features/DebugArea/Views/Toolbar/FilterTextField.swift @@ -10,11 +10,9 @@ import SwiftUI struct FilterTextField: View { let title: String - @Binding - var text: String + @Binding var text: String - @FocusState - private var isFocused: Bool + @FocusState private var isFocused: Bool var body: some View { HStack(spacing: 5) { diff --git a/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarClearButton.swift b/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarClearButton.swift index 5226c03e9..f8577e18f 100644 --- a/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarClearButton.swift +++ b/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarClearButton.swift @@ -8,8 +8,7 @@ import SwiftUI struct StatusBarClearButton: View { - @EnvironmentObject - private var model: DebugAreaViewModel + @EnvironmentObject private var model: DebugAreaViewModel var body: some View { Button { diff --git a/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarMaximizeButton.swift b/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarMaximizeButton.swift index dba43ca8e..907aaf0f8 100644 --- a/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarMaximizeButton.swift +++ b/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarMaximizeButton.swift @@ -8,8 +8,7 @@ import SwiftUI struct StatusBarMaximizeButton: View { - @EnvironmentObject - private var model: DebugAreaViewModel + @EnvironmentObject private var model: DebugAreaViewModel var body: some View { Button { diff --git a/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarSplitTerminalButton.swift b/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarSplitTerminalButton.swift index 17a8543fb..48c90758b 100644 --- a/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarSplitTerminalButton.swift +++ b/CodeEdit/Features/DebugArea/Views/Toolbar/StatusBarSplitTerminalButton.swift @@ -8,8 +8,7 @@ import SwiftUI struct StatusBarSplitTerminalButton: View { - @EnvironmentObject - private var model: DebugAreaViewModel + @EnvironmentObject private var model: DebugAreaViewModel var body: some View { Button { diff --git a/CodeEdit/Features/Documents/Views/WorkspaceCodeFileView.swift b/CodeEdit/Features/Documents/Views/WorkspaceCodeFileView.swift index 5f8f54d3b..22b741e91 100644 --- a/CodeEdit/Features/Documents/Views/WorkspaceCodeFileView.swift +++ b/CodeEdit/Features/Documents/Views/WorkspaceCodeFileView.swift @@ -10,16 +10,13 @@ import UniformTypeIdentifiers struct WorkspaceCodeFileView: View { - @EnvironmentObject - private var tabManager: TabManager + @EnvironmentObject private var tabManager: TabManager - @EnvironmentObject - private var tabgroup: TabGroupData + @EnvironmentObject private var tabgroup: TabGroupData var file: CEWorkspaceFile - @ViewBuilder - var codeView: some View { + @ViewBuilder var codeView: some View { if let document = file.fileDocument { Group { switch document.typeOfFile { diff --git a/CodeEdit/Features/Documents/WorkspaceDocument+Listeners.swift b/CodeEdit/Features/Documents/WorkspaceDocument+Listeners.swift index 8d79dca9f..70bc18e78 100644 --- a/CodeEdit/Features/Documents/WorkspaceDocument+Listeners.swift +++ b/CodeEdit/Features/Documents/WorkspaceDocument+Listeners.swift @@ -10,8 +10,7 @@ import Combine class WorkspaceNotificationModel: ObservableObject { - @Published - var highlightedFileItem: CEWorkspaceFile? + @Published var highlightedFileItem: CEWorkspaceFile? init() { highlightedFileItem = nil diff --git a/CodeEdit/Features/Documents/WorkspaceDocument.swift b/CodeEdit/Features/Documents/WorkspaceDocument.swift index b0431305c..3ffb95912 100644 --- a/CodeEdit/Features/Documents/WorkspaceDocument.swift +++ b/CodeEdit/Features/Documents/WorkspaceDocument.swift @@ -10,7 +10,8 @@ import AppKit import SwiftUI import Combine -@objc(WorkspaceDocument) final class WorkspaceDocument: NSDocument, ObservableObject, NSToolbarDelegate { +@objc(WorkspaceDocument) +final class WorkspaceDocument: NSDocument, ObservableObject, NSToolbarDelegate { @Published var sortFoldersOnTop: Bool = true @@ -215,7 +216,8 @@ import Combine /// `shouldClose` becomes false if the user selects cancel, otherwise true. /// - contextInfo: The additional info which will be set `shouldClose`. /// `contextInfo` must be `UnsafeMutablePointer`. - @objc func document( + @objc + func document( _ document: NSDocument, shouldClose: Bool, contextInfo: UnsafeMutableRawPointer diff --git a/CodeEdit/Features/Extensions/ExtensionSceneView.swift b/CodeEdit/Features/Extensions/ExtensionSceneView.swift index e97aedb3b..83e864bff 100644 --- a/CodeEdit/Features/Extensions/ExtensionSceneView.swift +++ b/CodeEdit/Features/Extensions/ExtensionSceneView.swift @@ -12,7 +12,8 @@ import ExtensionFoundation struct ExtensionSceneView: NSViewControllerRepresentable { - @Environment(\.openWindow) var openWindow + @Environment(\.openWindow) + var openWindow let appExtension: AppExtensionIdentity let sceneID: String diff --git a/CodeEdit/Features/Feedback/FeedbackView.swift b/CodeEdit/Features/Feedback/FeedbackView.swift index 6a9f0d121..03586cc84 100644 --- a/CodeEdit/Features/Feedback/FeedbackView.swift +++ b/CodeEdit/Features/Feedback/FeedbackView.swift @@ -8,14 +8,11 @@ import SwiftUI struct FeedbackView: View { - @ObservedObject - private var feedbackModel: FeedbackModel = .shared + @ObservedObject private var feedbackModel: FeedbackModel = .shared - @State - var showsAlert: Bool = false + @State var showsAlert: Bool = false - @State - var isSubmitButtonPressed: Bool = false + @State var isSubmitButtonPressed: Bool = false var body: some View { VStack { diff --git a/CodeEdit/Features/Feedback/Model/FeedbackModel.swift b/CodeEdit/Features/Feedback/Model/FeedbackModel.swift index 998b71781..589e76269 100644 --- a/CodeEdit/Features/Feedback/Model/FeedbackModel.swift +++ b/CodeEdit/Features/Feedback/Model/FeedbackModel.swift @@ -13,43 +13,37 @@ public class FeedbackModel: ObservableObject { private let keychain = CodeEditKeychain() - @Environment(\.openURL) var openIssueURL - - @Published - var isSubmitted: Bool = false - @Published - var failedToSubmit: Bool = false - @Published - var feedbackTitle: String = "" - @Published - var issueDescription: String = "" - @Published - var stepsReproduceDescription: String = "" - @Published - var expectationDescription: String = "" - @Published - var whatHappenedDescription: String = "" - @Published - var issueAreaListSelection: FeedbackIssueArea.ID = "none" - @Published - var feedbackTypeListSelection: FeedbackType.ID = "none" - - @Published - var feedbackTypeList = [FeedbackType(name: "Choose...", id: "none"), - FeedbackType(name: "Incorrect/Unexpected Behaviour", id: "behaviour"), - FeedbackType(name: "Application Crash", id: "crash"), - FeedbackType(name: "Application Slow/Unresponsive", id: "unresponsive"), - FeedbackType(name: "Suggestion", id: "suggestions"), - FeedbackType(name: "Other", id: "other")] - - @Published - var issueAreaList = [FeedbackIssueArea(name: "Please select the problem area", id: "none"), - FeedbackIssueArea(name: "Project Navigator", id: "projectNavigator"), - FeedbackIssueArea(name: "Extensions", id: "extensions"), - FeedbackIssueArea(name: "Git", id: "git"), - FeedbackIssueArea(name: "Debugger", id: "debugger"), - FeedbackIssueArea(name: "Editor", id: "editor"), - FeedbackIssueArea(name: "Other", id: "other")] + @Environment(\.openURL) + var openIssueURL + + @Published var isSubmitted: Bool = false + @Published var failedToSubmit: Bool = false + @Published var feedbackTitle: String = "" + @Published var issueDescription: String = "" + @Published var stepsReproduceDescription: String = "" + @Published var expectationDescription: String = "" + @Published var whatHappenedDescription: String = "" + @Published var issueAreaListSelection: FeedbackIssueArea.ID = "none" + @Published var feedbackTypeListSelection: FeedbackType.ID = "none" + + @Published var feedbackTypeList = [ + FeedbackType(name: "Choose...", id: "none"), + FeedbackType(name: "Incorrect/Unexpected Behaviour", id: "behaviour"), + FeedbackType(name: "Application Crash", id: "crash"), + FeedbackType(name: "Application Slow/Unresponsive", id: "unresponsive"), + FeedbackType(name: "Suggestion", id: "suggestions"), + FeedbackType(name: "Other", id: "other") + ] + + @Published var issueAreaList = [ + FeedbackIssueArea(name: "Please select the problem area", id: "none"), + FeedbackIssueArea(name: "Project Navigator", id: "projectNavigator"), + FeedbackIssueArea(name: "Extensions", id: "extensions"), + FeedbackIssueArea(name: "Git", id: "git"), + FeedbackIssueArea(name: "Debugger", id: "debugger"), + FeedbackIssueArea(name: "Editor", id: "editor"), + FeedbackIssueArea(name: "Other", id: "other") + ] /// Gets the ID of the selected issue type and then /// cross references it to select the right Label based on the type diff --git a/CodeEdit/Features/InspectorSidebar/InspectorSidebarToolbarTop.swift b/CodeEdit/Features/InspectorSidebar/InspectorSidebarToolbarTop.swift index 3e75b8bd7..2c9236abc 100644 --- a/CodeEdit/Features/InspectorSidebar/InspectorSidebarToolbarTop.swift +++ b/CodeEdit/Features/InspectorSidebar/InspectorSidebarToolbarTop.swift @@ -10,9 +10,7 @@ import SwiftUI struct InspectorSidebarToolbarTop: View { var items: [InspectorTab] - @Binding - var selection: InspectorTab - + @Binding var selection: InspectorTab @State private var targeted: Bool = true @State private var icons = [ InspectorDockIcon(imageName: "doc", title: "File Inspector", id: 0), diff --git a/CodeEdit/Features/InspectorSidebar/InspectorSidebarView.swift b/CodeEdit/Features/InspectorSidebar/InspectorSidebarView.swift index a8c32d088..c0767e8c2 100644 --- a/CodeEdit/Features/InspectorSidebar/InspectorSidebarView.swift +++ b/CodeEdit/Features/InspectorSidebar/InspectorSidebarView.swift @@ -8,20 +8,16 @@ import SwiftUI struct InspectorSidebarView: View { - @EnvironmentObject - private var workspace: WorkspaceDocument + @EnvironmentObject private var workspace: WorkspaceDocument - @ObservedObject - private var extensionManager = ExtensionManager.shared + @ObservedObject private var extensionManager = ExtensionManager.shared - @EnvironmentObject - private var tabManager: TabManager + @EnvironmentObject private var tabManager: TabManager @AppSettings(\.general.inspectorTabBarPosition) var sidebarPosition: SettingsData.SidebarTabBarPosition - @State - private var selection: InspectorTab? = .quickhelp + @State private var selection: InspectorTab? = .quickhelp var path: String? { tabManager.activeTabGroup.selected?.fileDocument?.fileURL?.path(percentEncoded: false) } diff --git a/CodeEdit/Features/InspectorSidebar/Models/FileInspectorModel.swift b/CodeEdit/Features/InspectorSidebar/Models/FileInspectorModel.swift index bff0d6dd4..d032c7449 100644 --- a/CodeEdit/Features/InspectorSidebar/Models/FileInspectorModel.swift +++ b/CodeEdit/Features/InspectorSidebar/Models/FileInspectorModel.swift @@ -12,86 +12,64 @@ public final class FileInspectorModel: ObservableObject { /// The base URL of the workspace private(set) var workspaceURL: URL - @Published - var fileTypeSelection: LanguageType.ID = "swift" - @Published - var fileURL: String = "" - @Published - var fileName: String = "" + @Published var fileTypeSelection: LanguageType.ID = "swift" + @Published var fileURL: String = "" + @Published var fileName: String = "" - @Published - var locationSelection: FileLocation.ID = "relative_group" - @Published - var textEncodingSelection: TextEncoding.ID = "utf8" - @Published - var lineEndingsSelection: LineEndings.ID = "macos" - @Published - var indentUsingSelection: IndentUsing.ID = "spaces" + @Published var locationSelection: FileLocation.ID = "relative_group" + @Published var textEncodingSelection: TextEncoding.ID = "utf8" + @Published var lineEndingsSelection: LineEndings.ID = "macos" + @Published var indentUsingSelection: IndentUsing.ID = "spaces" - @Published - var languageTypeObjCList = FileTypeList.init().languageTypeObjCList - @Published - var sourcecodeCList = FileTypeList.init().sourcecodeCList - @Published - var sourcecodeCPlusList = FileTypeList.init().sourcecodeCPlusList - @Published - var sourcecodeSwiftList = FileTypeList.init().sourcecodeSwiftList - @Published - var sourcecodeAssemblyList = FileTypeList.init().sourcecodeAssemblyList - @Published - var sourcecodeScriptList = FileTypeList.init().sourcecodeScriptList - @Published - var sourcecodeVariousList = FileTypeList.init().sourcecodeVariousList - @Published - var propertyList = FileTypeList.init().propertyList - @Published - var shellList = FileTypeList.init().shellList - @Published - var machOList = FileTypeList.init().machOList - @Published - var textList = FileTypeList.init().textList - @Published - var audioList = FileTypeList.init().audioList - @Published - var imageList = FileTypeList.init().imageList - @Published - var videoList = FileTypeList.init().videoList - @Published - var archiveList = FileTypeList.init().archiveList - @Published - var otherList = FileTypeList.init().otherList + @Published var languageTypeObjCList = FileTypeList.init().languageTypeObjCList + @Published var sourcecodeCList = FileTypeList.init().sourcecodeCList + @Published var sourcecodeCPlusList = FileTypeList.init().sourcecodeCPlusList + @Published var sourcecodeSwiftList = FileTypeList.init().sourcecodeSwiftList + @Published var sourcecodeAssemblyList = FileTypeList.init().sourcecodeAssemblyList + @Published var sourcecodeScriptList = FileTypeList.init().sourcecodeScriptList + @Published var sourcecodeVariousList = FileTypeList.init().sourcecodeVariousList + @Published var propertyList = FileTypeList.init().propertyList + @Published var shellList = FileTypeList.init().shellList + @Published var machOList = FileTypeList.init().machOList + @Published var textList = FileTypeList.init().textList + @Published var audioList = FileTypeList.init().audioList + @Published var imageList = FileTypeList.init().imageList + @Published var videoList = FileTypeList.init().videoList + @Published var archiveList = FileTypeList.init().archiveList + @Published var otherList = FileTypeList.init().otherList - @Published - var locationList = [FileLocation(name: "Absolute Path", id: "absolute"), - FileLocation(name: "Relative to Group", id: "relative_group"), - FileLocation(name: "Relative to Project", id: "relative_project"), - FileLocation(name: "Relative to Developer Directory", id: "relative_developer_dir"), - FileLocation(name: "Relative to Build Projects", id: "relative_build_projects"), - FileLocation(name: "Relative to SDK", id: "relative_sdk")] + @Published var locationList = [ + FileLocation(name: "Absolute Path", id: "absolute"), + FileLocation(name: "Relative to Group", id: "relative_group"), + FileLocation(name: "Relative to Project", id: "relative_project"), + FileLocation(name: "Relative to Developer Directory", id: "relative_developer_dir"), + FileLocation(name: "Relative to Build Projects", id: "relative_build_projects"), + FileLocation(name: "Relative to SDK", id: "relative_sdk") + ] - @Published - var textEncodingList = [TextEncoding(name: "Unicode (UTF-8)", id: "utf8"), - TextEncoding(name: "Unicode (UTF-16)", id: "utf16"), - TextEncoding(name: "Unicode (UTF-16BE)", id: "utf16_be"), - TextEncoding(name: "Unicode (UTF-16LE)", id: "utf16_le")] + @Published var textEncodingList = [ + TextEncoding(name: "Unicode (UTF-8)", id: "utf8"), + TextEncoding(name: "Unicode (UTF-16)", id: "utf16"), + TextEncoding(name: "Unicode (UTF-16BE)", id: "utf16_be"), + TextEncoding(name: "Unicode (UTF-16LE)", id: "utf16_le") + ] - @Published - var lineEndingsList = [LineEndings(name: "macOS / Unix (LF)", id: "macos"), - LineEndings(name: "Classic macOS (CR)", id: "classic"), - LineEndings(name: "Windows (CRLF)", id: "windows")] + @Published var lineEndingsList = [ + LineEndings(name: "macOS / Unix (LF)", id: "macos"), + LineEndings(name: "Classic macOS (CR)", id: "classic"), + LineEndings(name: "Windows (CRLF)", id: "windows") + ] - @Published - var indentUsingList = [IndentUsing(name: "Spaces", id: "spaces"), - IndentUsing(name: "Tabs", id: "tabs")] + @Published var indentUsingList = [ + IndentUsing(name: "Spaces", id: "spaces"), + IndentUsing(name: "Tabs", id: "tabs") + ] - @Published - var tabWidth: Int = 4 + @Published var tabWidth: Int = 4 - @Published - var indentWidth: Int = 4 + @Published var indentWidth: Int = 4 - @Published - var wrapLines: Bool = true + @Published var wrapLines: Bool = true public init(workspaceURL: URL, fileURL: String) { self.workspaceURL = workspaceURL diff --git a/CodeEdit/Features/InspectorSidebar/Models/HistoryInspectorModel.swift b/CodeEdit/Features/InspectorSidebar/Models/HistoryInspectorModel.swift index ac40d2d56..c859e7107 100644 --- a/CodeEdit/Features/InspectorSidebar/Models/HistoryInspectorModel.swift +++ b/CodeEdit/Features/InspectorSidebar/Models/HistoryInspectorModel.swift @@ -19,8 +19,7 @@ final class HistoryInspectorModel: ObservableObject { private(set) var fileURL: String /// The selected branch from the GitClient - @Published - var commitHistory: [GitCommit] + @Published var commitHistory: [GitCommit] /// Initialize with a GitClient /// - Parameter workspaceURL: the current workspace URL diff --git a/CodeEdit/Features/InspectorSidebar/Views/FileInspectorView.swift b/CodeEdit/Features/InspectorSidebar/Views/FileInspectorView.swift index a68396a7b..ca178c14a 100644 --- a/CodeEdit/Features/InspectorSidebar/Views/FileInspectorView.swift +++ b/CodeEdit/Features/InspectorSidebar/Views/FileInspectorView.swift @@ -8,8 +8,7 @@ import SwiftUI struct FileInspectorView: View { - @ObservedObject - private var inspectorModel: FileInspectorModel + @ObservedObject private var inspectorModel: FileInspectorModel /// Initialize with GitClient /// - Parameter gitClient: a GitClient diff --git a/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorItemView.swift b/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorItemView.swift index 8c286648a..9ec5595c2 100644 --- a/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorItemView.swift +++ b/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorItemView.swift @@ -24,7 +24,8 @@ struct HistoryInspectorItemView: View { } } - @Environment(\.openURL) private var openCommit + @Environment(\.openURL) + private var openCommit init(commit: GitCommit, selection: Binding) { self.commit = commit diff --git a/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorView.swift b/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorView.swift index 279f06b6a..d3ece039f 100644 --- a/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorView.swift +++ b/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorView.swift @@ -8,8 +8,7 @@ import SwiftUI struct HistoryInspectorView: View { - @ObservedObject - private var model: HistoryInspectorModel + @ObservedObject private var model: HistoryInspectorModel @State var selectedCommitHistory: GitCommit? diff --git a/CodeEdit/Features/InspectorSidebar/Views/Popover/HistoryPopoverView.swift b/CodeEdit/Features/InspectorSidebar/Views/Popover/HistoryPopoverView.swift index 5267743bc..1c6c19664 100644 --- a/CodeEdit/Features/InspectorSidebar/Views/Popover/HistoryPopoverView.swift +++ b/CodeEdit/Features/InspectorSidebar/Views/Popover/HistoryPopoverView.swift @@ -86,10 +86,10 @@ struct HistoryPopoverView: View { private var image: String private var action: () -> Void - @State - private var isHovering: Bool = false + @State private var isHovering: Bool = false - @Environment(\.isEnabled) private var isEnabled + @Environment(\.isEnabled) + private var isEnabled init(_ title: String, systemImage: String, action: @escaping () -> Void) { self.title = title diff --git a/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorModeSelector.swift b/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorModeSelector.swift index c65b2f328..44a66e606 100644 --- a/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorModeSelector.swift +++ b/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorModeSelector.swift @@ -8,11 +8,9 @@ import SwiftUI struct FindNavigatorModeSelector: View { - @ObservedObject - private var state: WorkspaceDocument.SearchState + @ObservedObject private var state: WorkspaceDocument.SearchState - @State - private var selectedMode: [SearchModeModel] { + @State private var selectedMode: [SearchModeModel] { didSet { // sync the variables, as selectedMode is an array // and cannot be synced directly with @ObservedObject diff --git a/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorResultFileItem.swift b/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorResultFileItem.swift index 281fa4048..c29f6c47f 100644 --- a/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorResultFileItem.swift +++ b/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorResultFileItem.swift @@ -11,13 +11,9 @@ import Search import AppPreferences struct FindNavigatorResultFileItem: View { - @ObservedObject - private var state: WorkspaceDocument.SearchState - @StateObject - private var prefs: AppPreferencesModel = .shared - - @State - private var isExpanded: Bool = true + @ObservedObject private var state: WorkspaceDocument.SearchState + @StateObject private var prefs: AppPreferencesModel = .shared + @State private var isExpanded: Bool = true private var fileItem: WorkspaceClient.FileItem private var results: [SearchResultModel] diff --git a/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorResultList/FindNavigatorResultList.swift b/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorResultList/FindNavigatorResultList.swift index 1fcb1e3d5..8e5449ef2 100644 --- a/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorResultList/FindNavigatorResultList.swift +++ b/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorResultList/FindNavigatorResultList.swift @@ -10,10 +10,10 @@ import Combine struct FindNavigatorResultList: NSViewControllerRepresentable { - @EnvironmentObject - var workspace: WorkspaceDocument + @EnvironmentObject var workspace: WorkspaceDocument - @AppSettings(\.general.projectNavigatorSize) var projectNavigatorSize + @AppSettings(\.general.projectNavigatorSize) + var projectNavigatorSize typealias NSViewControllerType = FindNavigatorListViewController diff --git a/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorSearchBar.swift b/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorSearchBar.swift index bd0006394..2a0d992cf 100644 --- a/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorSearchBar.swift +++ b/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorSearchBar.swift @@ -11,16 +11,13 @@ struct FindNavigatorSearchBar: View { @Environment(\.colorScheme) var colorScheme - @ObservedObject - private var state: WorkspaceDocument.SearchState + @ObservedObject private var state: WorkspaceDocument.SearchState - @FocusState - private var isFocused: Bool + @FocusState private var isFocused: Bool private let title: String - @Binding - private var text: String + @Binding private var text: String @Environment(\.controlActiveState) private var controlActive diff --git a/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorView.swift b/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorView.swift index 6386e6987..1b144249e 100644 --- a/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorView.swift +++ b/CodeEdit/Features/NavigatorSidebar/FindNavigator/FindNavigatorView.swift @@ -9,15 +9,13 @@ import SwiftUI struct FindNavigatorView: View { - @EnvironmentObject - private var workspace: WorkspaceDocument + @EnvironmentObject private var workspace: WorkspaceDocument private var state: WorkspaceDocument.SearchState { workspace.searchState ?? .init(workspace) } - @State - private var searchText: String = "" + @State private var searchText: String = "" enum Filters: String { case ignoring = "Ignoring Case" @@ -26,11 +24,9 @@ struct FindNavigatorView: View { @State var currentFilter: String = "" - @State - private var foundFilesCount: Int = 0 + @State private var foundFilesCount: Int = 0 - @State - private var searchResultCount: Int = 0 + @State private var searchResultCount: Int = 0 var body: some View { VStack { diff --git a/CodeEdit/Features/NavigatorSidebar/NavigatorSidebarToolbar.swift b/CodeEdit/Features/NavigatorSidebar/NavigatorSidebarToolbar.swift index e8d83ed20..c6d2ace5a 100644 --- a/CodeEdit/Features/NavigatorSidebar/NavigatorSidebarToolbar.swift +++ b/CodeEdit/Features/NavigatorSidebar/NavigatorSidebarToolbar.swift @@ -14,8 +14,7 @@ struct NavigatorSidebarToolbar: View { var alignment: SidebarToolbarAlignment - @Binding - private var selection: Int + @Binding private var selection: Int @State private var icons = [ SidebarDockIcon(imageName: "folder", title: "Project", id: 0), diff --git a/CodeEdit/Features/NavigatorSidebar/NavigatorSidebarView.swift b/CodeEdit/Features/NavigatorSidebar/NavigatorSidebarView.swift index 85ed1a7d7..9d81d244f 100644 --- a/CodeEdit/Features/NavigatorSidebar/NavigatorSidebarView.swift +++ b/CodeEdit/Features/NavigatorSidebar/NavigatorSidebarView.swift @@ -8,17 +8,14 @@ import SwiftUI struct NavigatorSidebarView: View { - @ObservedObject - private var workspace: WorkspaceDocument + @ObservedObject private var workspace: WorkspaceDocument - @ObservedObject - private var extensionManager = ExtensionManager.shared + @ObservedObject private var extensionManager = ExtensionManager.shared @AppSettings(\.general.navigatorTabBarPosition) var sidebarPosition: SettingsData.SidebarTabBarPosition - @State - private var selection: NavigatorTab? = .project + @State private var selection: NavigatorTab? = .project init(workspace: WorkspaceDocument) { self.workspace = workspace diff --git a/CodeEdit/Features/NavigatorSidebar/ProjectNavigator/OutlineView/ProjectNavigatorOutlineView.swift b/CodeEdit/Features/NavigatorSidebar/ProjectNavigator/OutlineView/ProjectNavigatorOutlineView.swift index 57421c563..9b5d6a93c 100644 --- a/CodeEdit/Features/NavigatorSidebar/ProjectNavigator/OutlineView/ProjectNavigatorOutlineView.swift +++ b/CodeEdit/Features/NavigatorSidebar/ProjectNavigator/OutlineView/ProjectNavigatorOutlineView.swift @@ -11,11 +11,9 @@ import Combine /// Wraps an ``OutlineViewController`` inside a `NSViewControllerRepresentable` struct ProjectNavigatorOutlineView: NSViewControllerRepresentable { - @EnvironmentObject - var workspace: WorkspaceDocument + @EnvironmentObject var workspace: WorkspaceDocument - @StateObject - var prefs: Settings = .shared + @StateObject var prefs: Settings = .shared typealias NSViewControllerType = ProjectNavigatorViewController diff --git a/CodeEdit/Features/NavigatorSidebar/ProjectNavigator/ProjectNavigatorToolbarBottom.swift b/CodeEdit/Features/NavigatorSidebar/ProjectNavigator/ProjectNavigatorToolbarBottom.swift index 2a1bf81ed..52cc88a72 100644 --- a/CodeEdit/Features/NavigatorSidebar/ProjectNavigator/ProjectNavigatorToolbarBottom.swift +++ b/CodeEdit/Features/NavigatorSidebar/ProjectNavigator/ProjectNavigatorToolbarBottom.swift @@ -14,11 +14,9 @@ struct ProjectNavigatorToolbarBottom: View { @Environment(\.colorScheme) private var colorScheme - @EnvironmentObject - var workspace: WorkspaceDocument + @EnvironmentObject var workspace: WorkspaceDocument - @State - var filter: String = "" + @State var filter: String = "" var body: some View { HStack { diff --git a/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Model/SourceControlModel.swift b/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Model/SourceControlModel.swift index 278448911..5dc1de304 100644 --- a/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Model/SourceControlModel.swift +++ b/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Model/SourceControlModel.swift @@ -18,8 +18,7 @@ final class SourceControlModel: ObservableObject { let workspaceURL: URL /// A list of changed files - @Published - var changed: [GitChangedFile] + @Published var changed: [GitChangedFile] /// Initialize with a GitClient /// - Parameter workspaceURL: the current workspace URL we also need this to open files in finder diff --git a/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/SourceControlNavigatorView.swift b/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/SourceControlNavigatorView.swift index dec508908..eb3a0660a 100644 --- a/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/SourceControlNavigatorView.swift +++ b/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/SourceControlNavigatorView.swift @@ -9,11 +9,9 @@ import SwiftUI struct SourceControlNavigatorView: View { - @EnvironmentObject - private var workspace: WorkspaceDocument + @EnvironmentObject private var workspace: WorkspaceDocument - @State - private var selectedSection: Int = 0 + @State private var selectedSection: Int = 0 var body: some View { VStack { diff --git a/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/SourceControlSearchToolbar.swift b/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/SourceControlSearchToolbar.swift index 6d7ac72e1..894dcad42 100644 --- a/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/SourceControlSearchToolbar.swift +++ b/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/SourceControlSearchToolbar.swift @@ -15,8 +15,7 @@ struct SourceControlSearchToolbar: View { @Environment(\.controlActiveState) private var controlActive - @State - private var text = "" + @State private var text = "" var body: some View { HStack { diff --git a/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangedFileView.swift b/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangedFileView.swift index 48332d59a..8d05886b8 100644 --- a/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangedFileView.swift +++ b/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangedFileView.swift @@ -9,14 +9,11 @@ import SwiftUI struct SourceControlNavigatorChangedFileView: View { - @State - var changedFile: GitChangedFile + @State var changedFile: GitChangedFile - @Binding - var selection: GitChangedFile.ID? + @Binding var selection: GitChangedFile.ID? - @State - var workspaceURL: URL + @State var workspaceURL: URL var body: some View { HStack { diff --git a/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangesView.swift b/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangesView.swift index 6d4037e19..68d2c782b 100644 --- a/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangesView.swift +++ b/CodeEdit/Features/NavigatorSidebar/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangesView.swift @@ -9,11 +9,9 @@ import SwiftUI struct SourceControlNavigatorChangesView: View { - @ObservedObject - var model: SourceControlModel + @ObservedObject var model: SourceControlModel - @State - var selectedFile: GitChangedFile.ID? + @State var selectedFile: GitChangedFile.ID? /// Initialize with GitClient /// - Parameter gitClient: a GitClient diff --git a/CodeEdit/Features/PathBar/Views/PathBarComponent.swift b/CodeEdit/Features/PathBar/Views/PathBarComponent.swift index c114a9fcf..525e2b6fa 100644 --- a/CodeEdit/Features/PathBar/Views/PathBarComponent.swift +++ b/CodeEdit/Features/PathBar/Views/PathBarComponent.swift @@ -19,11 +19,9 @@ struct PathBarComponent: View { @Environment(\.controlActiveState) private var activeState - @State - var position: NSPoint? + @State var position: NSPoint? - @State - var selection: CEWorkspaceFile + @State var selection: CEWorkspaceFile init( fileItem: CEWorkspaceFile, @@ -57,8 +55,7 @@ struct PathBarComponent: View { } struct NSPopUpButtonView: NSViewRepresentable where ItemType: Equatable { - @Binding - var selection: ItemType + @Binding var selection: ItemType var popupCreator: () -> NSPopUpButton diff --git a/CodeEdit/Features/PathBar/Views/PathBarMenu.swift b/CodeEdit/Features/PathBar/Views/PathBarMenu.swift index 76da34bba..1452283d4 100644 --- a/CodeEdit/Features/PathBar/Views/PathBarMenu.swift +++ b/CodeEdit/Features/PathBar/Views/PathBarMenu.swift @@ -94,7 +94,8 @@ final class PathBarMenuItem: NSMenuItem { fatalError("init(coder:) has not been implemented") } - @objc func openFile() { + @objc + func openFile() { tappedOpenFile(fileItem) } } diff --git a/CodeEdit/Features/QuickOpen/ViewModels/QuickOpenViewModel.swift b/CodeEdit/Features/QuickOpen/ViewModels/QuickOpenViewModel.swift index 7c0f9fa23..0d695b347 100644 --- a/CodeEdit/Features/QuickOpen/ViewModels/QuickOpenViewModel.swift +++ b/CodeEdit/Features/QuickOpen/ViewModels/QuickOpenViewModel.swift @@ -10,14 +10,11 @@ import Foundation final class QuickOpenViewModel: ObservableObject { - @Published - var openQuicklyQuery: String = "" + @Published var openQuicklyQuery: String = "" - @Published - var openQuicklyFiles: [CEWorkspaceFile] = [] + @Published var openQuicklyFiles: [CEWorkspaceFile] = [] - @Published - var isShowingOpenQuicklyFiles: Bool = false + @Published var isShowingOpenQuicklyFiles: Bool = false let fileURL: URL diff --git a/CodeEdit/Features/QuickOpen/Views/QuickOpenPreviewView.swift b/CodeEdit/Features/QuickOpen/Views/QuickOpenPreviewView.swift index f99008380..38ba4953d 100644 --- a/CodeEdit/Features/QuickOpen/Views/QuickOpenPreviewView.swift +++ b/CodeEdit/Features/QuickOpen/Views/QuickOpenPreviewView.swift @@ -12,8 +12,7 @@ struct QuickOpenPreviewView: View { private let queue = DispatchQueue(label: "app.codeedit.CodeEdit.quickOpen.preview") private let item: CEWorkspaceFile - @ObservedObject - var document: CodeFileDocument + @ObservedObject var document: CodeFileDocument init( item: CEWorkspaceFile diff --git a/CodeEdit/Features/QuickOpen/Views/QuickOpenView.swift b/CodeEdit/Features/QuickOpen/Views/QuickOpenView.swift index e87158c7e..13ab3f230 100644 --- a/CodeEdit/Features/QuickOpen/Views/QuickOpenView.swift +++ b/CodeEdit/Features/QuickOpen/Views/QuickOpenView.swift @@ -12,11 +12,9 @@ struct QuickOpenView: View { private let onClose: () -> Void private let openFile: (CEWorkspaceFile) -> Void - @ObservedObject - private var state: QuickOpenViewModel + @ObservedObject private var state: QuickOpenViewModel - @State - private var selectedItem: CEWorkspaceFile? + @State private var selectedItem: CEWorkspaceFile? init( state: QuickOpenViewModel, diff --git a/CodeEdit/Features/Settings/Models/Settings.swift b/CodeEdit/Features/Settings/Models/Settings.swift index 21bcda4b4..deee382eb 100644 --- a/CodeEdit/Features/Settings/Models/Settings.swift +++ b/CodeEdit/Features/Settings/Models/Settings.swift @@ -44,8 +44,7 @@ final class Settings: ObservableObject { /// Published instance of the ``Settings`` model. /// /// Changes are saved automatically. - @Published - var preferences: SettingsData + @Published var preferences: SettingsData /// Load and construct ``Settings`` model from /// `~/Library/Application Support/CodeEdit/settings.json` diff --git a/CodeEdit/Features/Settings/Models/SettingsSidebarFix.swift b/CodeEdit/Features/Settings/Models/SettingsSidebarFix.swift index 3a2bdc446..d3076240e 100644 --- a/CodeEdit/Features/Settings/Models/SettingsSidebarFix.swift +++ b/CodeEdit/Features/Settings/Models/SettingsSidebarFix.swift @@ -9,9 +9,7 @@ import Foundation import AppKit extension NSSplitViewItem { - - @objc - fileprivate var canCollapseSwizzled: Bool { + @objc fileprivate var canCollapseSwizzled: Bool { if let check = self.viewController.view.window?.isSettingsWindow, check { return false } diff --git a/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountSelectionView.swift b/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountSelectionView.swift index 1b8fd678a..5d0db5d5b 100644 --- a/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountSelectionView.swift +++ b/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountSelectionView.swift @@ -8,7 +8,8 @@ import SwiftUI struct AccountSelectionView: View { - @Environment(\.dismiss) var dismiss + @Environment(\.dismiss) + var dismiss @Binding var selectedProvider: SourceControlAccount.Provider? diff --git a/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsDetailsView.swift b/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsDetailsView.swift index 64e915932..0f681eb85 100644 --- a/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsDetailsView.swift +++ b/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsDetailsView.swift @@ -8,9 +8,12 @@ import SwiftUI struct AccountsSettingsDetailsView: View { - @Environment(\.dismiss) private var dismiss - @AppSettings(\.accounts.sourceControlAccounts.sshKey) var sshKey - @AppSettings(\.accounts.sourceControlAccounts.gitAccounts) var gitAccounts + @Environment(\.dismiss) + private var dismiss + @AppSettings(\.accounts.sourceControlAccounts.sshKey) + var sshKey + @AppSettings(\.accounts.sourceControlAccounts.gitAccounts) + var gitAccounts @Binding var account: SourceControlAccount @State var currentAccount: SourceControlAccount diff --git a/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsSigninView.swift b/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsSigninView.swift index f7f57c44b..b2965e16a 100644 --- a/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsSigninView.swift +++ b/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsSigninView.swift @@ -8,8 +8,10 @@ import SwiftUI struct AccountsSettingsSigninView: View { - @Environment(\.dismiss) var dismiss - @Environment(\.openURL) var createToken + @Environment(\.dismiss) + var dismiss + @Environment(\.openURL) + var createToken var provider: SourceControlAccount.Provider @Binding var addAccountSheetPresented: Bool @@ -26,7 +28,8 @@ struct AccountsSettingsSigninView: View { @State var signinErrorAlertIsPresented: Bool = false @State var signinErrorDetail: String = "" - @AppSettings(\.accounts.sourceControlAccounts.gitAccounts) var gitAccounts + @AppSettings(\.accounts.sourceControlAccounts.gitAccounts) + var gitAccounts private let keychain = CodeEditKeychain() diff --git a/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsView.swift b/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsView.swift index 6d90c62cc..92926889c 100644 --- a/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsView.swift +++ b/CodeEdit/Features/Settings/Pages/AccountsSettings/AccountsSettingsView.swift @@ -8,7 +8,8 @@ import SwiftUI struct AccountsSettingsView: View { - @AppSettings(\.accounts.sourceControlAccounts.gitAccounts) var gitAccounts + @AppSettings(\.accounts.sourceControlAccounts.gitAccounts) + var gitAccounts @State private var addAccountSheetPresented: Bool = false @State private var selectedProvider: SourceControlAccount.Provider? diff --git a/CodeEdit/Features/Settings/Pages/AccountsSettings/CreateSSHKeyView.swift b/CodeEdit/Features/Settings/Pages/AccountsSettings/CreateSSHKeyView.swift index 81ff28d4f..d32d50ea4 100644 --- a/CodeEdit/Features/Settings/Pages/AccountsSettings/CreateSSHKeyView.swift +++ b/CodeEdit/Features/Settings/Pages/AccountsSettings/CreateSSHKeyView.swift @@ -8,7 +8,8 @@ import SwiftUI struct CreateSSHKeyView: View { - @Environment(\.dismiss) private var dismiss + @Environment(\.dismiss) + private var dismiss enum KeyType: String, CaseIterable { case ed25519 = "ED25519" diff --git a/CodeEdit/Features/Settings/Pages/GeneralSettings/GeneralSettingsView.swift b/CodeEdit/Features/Settings/Pages/GeneralSettings/GeneralSettingsView.swift index 5feaaf29f..d0480eb10 100644 --- a/CodeEdit/Features/Settings/Pages/GeneralSettings/GeneralSettingsView.swift +++ b/CodeEdit/Features/Settings/Pages/GeneralSettings/GeneralSettingsView.swift @@ -16,7 +16,8 @@ struct GeneralSettingsView: View { @EnvironmentObject var updater: SoftwareUpdater @FocusState private var focusedField: UUID? - @AppSettings(\.general) var settings + @AppSettings(\.general) + var settings @State private var openInCodeEdit: Bool = true diff --git a/CodeEdit/Features/Settings/Pages/LocationsSettings/LocationsSettingsView.swift b/CodeEdit/Features/Settings/Pages/LocationsSettings/LocationsSettingsView.swift index f995c9402..d6a287e10 100644 --- a/CodeEdit/Features/Settings/Pages/LocationsSettings/LocationsSettingsView.swift +++ b/CodeEdit/Features/Settings/Pages/LocationsSettings/LocationsSettingsView.swift @@ -22,8 +22,7 @@ struct LocationsSettingsView: View { } private extension LocationsSettingsView { - @ViewBuilder - private var applicationSupportLocation: some View { + @ViewBuilder private var applicationSupportLocation: some View { ExternalLink(destination: Settings.shared.baseURL) { Text("Application Support") Text(Settings.shared.baseURL.path) diff --git a/CodeEdit/Features/Settings/Pages/SourceControlSettings/SourceControlGeneralView.swift b/CodeEdit/Features/Settings/Pages/SourceControlSettings/SourceControlGeneralView.swift index ef66927db..2ef8c3b94 100644 --- a/CodeEdit/Features/Settings/Pages/SourceControlSettings/SourceControlGeneralView.swift +++ b/CodeEdit/Features/Settings/Pages/SourceControlSettings/SourceControlGeneralView.swift @@ -8,10 +8,10 @@ import SwiftUI struct SourceControlGeneralView: View { - @AppSettings(\.sourceControl.general) var settings + @AppSettings(\.sourceControl.general) + var settings - @State - private var text: String = "main" + @State private var text: String = "main" var body: some View { SettingsForm { diff --git a/CodeEdit/Features/Settings/Pages/SourceControlSettings/SourceControlGitView.swift b/CodeEdit/Features/Settings/Pages/SourceControlSettings/SourceControlGitView.swift index 011030a3d..504da5766 100644 --- a/CodeEdit/Features/Settings/Pages/SourceControlSettings/SourceControlGitView.swift +++ b/CodeEdit/Features/Settings/Pages/SourceControlSettings/SourceControlGitView.swift @@ -8,10 +8,10 @@ import SwiftUI struct SourceControlGitView: View { - @AppSettings(\.sourceControl.git) var git + @AppSettings(\.sourceControl.git) + var git - @State - var ignoredFileSelection: IgnoredFiles.ID? + @State var ignoredFileSelection: IgnoredFiles.ID? var body: some View { SettingsForm { diff --git a/CodeEdit/Features/Settings/Pages/TerminalSettings/TerminalSettingsView.swift b/CodeEdit/Features/Settings/Pages/TerminalSettings/TerminalSettingsView.swift index 12b6f7b38..1d305c946 100644 --- a/CodeEdit/Features/Settings/Pages/TerminalSettings/TerminalSettingsView.swift +++ b/CodeEdit/Features/Settings/Pages/TerminalSettings/TerminalSettingsView.swift @@ -8,7 +8,8 @@ import SwiftUI struct TerminalSettingsView: View { - @AppSettings(\.terminal) var settings + @AppSettings(\.terminal) + var settings var body: some View { SettingsForm { @@ -32,8 +33,7 @@ struct TerminalSettingsView: View { } private extension TerminalSettingsView { - @ViewBuilder - private var shellSelector: some View { + @ViewBuilder private var shellSelector: some View { Picker("Shell", selection: $settings.shell) { Text("System Default") .tag(SettingsData.TerminalShell.system) @@ -68,8 +68,7 @@ private extension TerminalSettingsView { Toggle("Use text editor font", isOn: $settings.useTextEditorFont) } - @ViewBuilder - private var fontSelector: some View { + @ViewBuilder private var fontSelector: some View { MonospacedFontPicker(title: "Font", selectedFontName: $settings.font.name) .onChange(of: settings.font.name) { fontName in settings.font.customFont = fontName != "SF Mono" diff --git a/CodeEdit/Features/Settings/Pages/TextEditingSettings/TextEditingSettingsView.swift b/CodeEdit/Features/Settings/Pages/TextEditingSettings/TextEditingSettingsView.swift index 7ea3e93fc..8bf1acea9 100644 --- a/CodeEdit/Features/Settings/Pages/TextEditingSettings/TextEditingSettingsView.swift +++ b/CodeEdit/Features/Settings/Pages/TextEditingSettings/TextEditingSettingsView.swift @@ -9,7 +9,8 @@ import SwiftUI /// A view that implements the `Text Editing` settings page struct TextEditingSettingsView: View { - @AppSettings(\.textEditing) var textEditing + @AppSettings(\.textEditing) + var textEditing var body: some View { SettingsForm { @@ -36,16 +37,14 @@ struct TextEditingSettingsView: View { } private extension TextEditingSettingsView { - @ViewBuilder - private var fontSelector: some View { + @ViewBuilder private var fontSelector: some View { MonospacedFontPicker(title: "Font", selectedFontName: $textEditing.font.name) .onChange(of: textEditing.font.name) { fontName in textEditing.font.customFont = fontName != "SF Mono" } } - @ViewBuilder - private var fontSizeSelector: some View { + @ViewBuilder private var fontSizeSelector: some View { Stepper( "Font Size", value: $textEditing.font.size, @@ -55,26 +54,22 @@ private extension TextEditingSettingsView { ) } - @ViewBuilder - private var autocompleteBraces: some View { + @ViewBuilder private var autocompleteBraces: some View { Toggle(isOn: $textEditing.autocompleteBraces) { Text("Autocomplete braces") Text("Automatically insert closing braces (\"}\")") } } - @ViewBuilder - private var enableTypeOverCompletion: some View { + @ViewBuilder private var enableTypeOverCompletion: some View { Toggle("Enable type-over completion", isOn: $textEditing.enableTypeOverCompletion) } - @ViewBuilder - private var wrapLinesToEditorWidth: some View { + @ViewBuilder private var wrapLinesToEditorWidth: some View { Toggle("Wrap lines to editor width", isOn: $textEditing.wrapLinesToEditorWidth) } - @ViewBuilder - private var lineHeight: some View { + @ViewBuilder private var lineHeight: some View { Stepper( "Line Height", value: $textEditing.lineHeightMultiple, @@ -84,8 +79,7 @@ private extension TextEditingSettingsView { ) } - @ViewBuilder - private var indentOption: some View { + @ViewBuilder private var indentOption: some View { Group { Picker("Prefer Indent Using", selection: $textEditing.indentOption.indentType) { Text("Tabs") @@ -113,8 +107,7 @@ private extension TextEditingSettingsView { } } - @ViewBuilder - private var defaultTabWidth: some View { + @ViewBuilder private var defaultTabWidth: some View { HStack(alignment: .top) { Stepper( "Tab Width", @@ -132,8 +125,7 @@ private extension TextEditingSettingsView { .help("The visual width of tabs.") } - @ViewBuilder - private var letterSpacing: some View { + @ViewBuilder private var letterSpacing: some View { Stepper( "Letter Spacing", value: $textEditing.letterSpacing, @@ -143,8 +135,7 @@ private extension TextEditingSettingsView { ) } - @ViewBuilder - private var bracketPairHighlight: some View { + @ViewBuilder private var bracketPairHighlight: some View { Group { Picker( "Braket Pair Highlight", diff --git a/CodeEdit/Features/Settings/Pages/ThemeSettings/Models/ThemeModel.swift b/CodeEdit/Features/Settings/Pages/ThemeSettings/Models/ThemeModel.swift index ba6b69598..4c3df1661 100644 --- a/CodeEdit/Features/Settings/Pages/ThemeSettings/Models/ThemeModel.swift +++ b/CodeEdit/Features/Settings/Pages/ThemeSettings/Models/ThemeModel.swift @@ -42,8 +42,7 @@ final class ThemeModel: ObservableObject { /// Selected 'light' theme /// Used for auto-switching theme to match macOS system appearance - @Published - var selectedLightTheme: Theme? { + @Published var selectedLightTheme: Theme? { didSet { DispatchQueue.main.async { Settings.shared @@ -54,8 +53,7 @@ final class ThemeModel: ObservableObject { /// Selected 'dark' theme /// Used for auto-switching theme to match macOS system appearance - @Published - var selectedDarkTheme: Theme? { + @Published var selectedDarkTheme: Theme? { didSet { DispatchQueue.main.async { Settings.shared @@ -67,27 +65,23 @@ final class ThemeModel: ObservableObject { /// The selected appearance in the sidebar. /// - **0**: dark mode themes /// - **1**: light mode themes - @Published - var selectedAppearance: Int = 0 + @Published var selectedAppearance: Int = 0 /// The selected tab in the main section. /// - **0**: Preview /// - **1**: Editor /// - **2**: Terminal - @Published - var selectedTab: Int = 1 + @Published var selectedTab: Int = 1 /// An array of loaded ``Theme``. - @Published - var themes: [Theme] = [] { + @Published var themes: [Theme] = [] { didSet { saveThemes() } } /// The currently selected ``Theme``. - @Published - var selectedTheme: Theme? { + @Published var selectedTheme: Theme? { didSet { DispatchQueue.main.async { Settings[\.theme].selectedTheme = self.selectedTheme?.name diff --git a/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsColorPreview.swift b/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsColorPreview.swift index c2196de0e..77f39f9f5 100644 --- a/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsColorPreview.swift +++ b/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsColorPreview.swift @@ -10,8 +10,7 @@ import SwiftUI struct ThemeSettingsColorPreview: View { var theme: Theme - @StateObject - private var themeModel: ThemeModel = .shared + @StateObject private var themeModel: ThemeModel = .shared @State private var displayName: String diff --git a/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsThemeDetails.swift b/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsThemeDetails.swift index b2edb7170..77ebfa777 100644 --- a/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsThemeDetails.swift +++ b/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsThemeDetails.swift @@ -8,14 +8,14 @@ import SwiftUI struct ThemeSettingsThemeDetails: View { - @Environment(\.dismiss) var dismiss + @Environment(\.dismiss) + var dismiss @Binding var theme: Theme @State private var initialTheme: Theme - @StateObject - private var themeModel: ThemeModel = .shared + @StateObject private var themeModel: ThemeModel = .shared init(_ theme: Binding) { _theme = theme diff --git a/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsView.swift b/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsView.swift index 3c4dea182..b3e44793c 100644 --- a/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsView.swift +++ b/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsView.swift @@ -9,10 +9,13 @@ import SwiftUI /// A view that implements the `Theme` preference section struct ThemeSettingsView: View { - @Environment(\.colorScheme) var colorScheme + @Environment(\.colorScheme) + var colorScheme @ObservedObject private var themeModel: ThemeModel = .shared - @AppSettings(\.theme) var settings - @AppSettings(\.terminal.darkAppearance) var useDarkTerminalAppearance + @AppSettings(\.theme) + var settings + @AppSettings(\.terminal.darkAppearance) + var useDarkTerminalAppearance @State private var listView: Bool = false @State private var selectedAppearance: ThemeSettingsAppearances = .dark diff --git a/CodeEdit/Features/Settings/SettingsView.swift b/CodeEdit/Features/Settings/SettingsView.swift index 1591d20e9..33634bee3 100644 --- a/CodeEdit/Features/Settings/SettingsView.swift +++ b/CodeEdit/Features/Settings/SettingsView.swift @@ -13,7 +13,8 @@ import Introspect /// A struct for settings struct SettingsView: View { @StateObject var model = SettingsViewModel() - @Environment(\.colorScheme) private var colorScheme + @Environment(\.colorScheme) + private var colorScheme /// An array of navigationItem(s) private static let pages: [SettingsPage] = [ @@ -37,7 +38,8 @@ struct SettingsView: View { @ObservedObject private var settings: Settings = .shared - @Environment(\.presentationMode) var presentationMode + @Environment(\.presentationMode) + var presentationMode let updater: SoftwareUpdater diff --git a/CodeEdit/Features/Settings/SoftwareUpdater.swift b/CodeEdit/Features/Settings/SoftwareUpdater.swift index 7337284df..bb7265658 100644 --- a/CodeEdit/Features/Settings/SoftwareUpdater.swift +++ b/CodeEdit/Features/Settings/SoftwareUpdater.swift @@ -13,18 +13,15 @@ class SoftwareUpdater: NSObject, ObservableObject, SPUUpdaterDelegate { private var automaticallyChecksForUpdatesObservation: NSKeyValueObservation? private var lastUpdateCheckDateObservation: NSKeyValueObservation? - @Published - var automaticallyChecksForUpdates = false { + @Published var automaticallyChecksForUpdates = false { didSet { updater?.automaticallyChecksForUpdates = automaticallyChecksForUpdates } } - @Published - var lastUpdateCheckDate: Date? + @Published var lastUpdateCheckDate: Date? - @Published - var includePrereleaseVersions = false { + @Published var includePrereleaseVersions = false { didSet { UserDefaults.standard.setValue(includePrereleaseVersions, forKey: "includePrereleaseVersions") } diff --git a/CodeEdit/Features/Settings/Views/SettingsForm.swift b/CodeEdit/Features/Settings/Views/SettingsForm.swift index c904f5c92..4701d1ac0 100644 --- a/CodeEdit/Features/Settings/Views/SettingsForm.swift +++ b/CodeEdit/Features/Settings/Views/SettingsForm.swift @@ -9,8 +9,10 @@ import SwiftUI import Introspect struct SettingsForm: View { - @Environment(\.colorScheme) private var colorScheme - @Environment(\.controlActiveState) private var activeState + @Environment(\.colorScheme) + private var colorScheme + @Environment(\.controlActiveState) + private var activeState @EnvironmentObject var model: SettingsViewModel @ViewBuilder var content: Content diff --git a/CodeEdit/Features/Settings/Views/View+NavigationBarBackButtonVisible.swift b/CodeEdit/Features/Settings/Views/View+NavigationBarBackButtonVisible.swift index 9c4dbb4e4..f778e0e79 100644 --- a/CodeEdit/Features/Settings/Views/View+NavigationBarBackButtonVisible.swift +++ b/CodeEdit/Features/Settings/Views/View+NavigationBarBackButtonVisible.swift @@ -8,7 +8,8 @@ import SwiftUI struct NavigationBarBackButtonVisible: ViewModifier { - @Environment(\.presentationMode) var presentationMode + @Environment(\.presentationMode) + var presentationMode @EnvironmentObject var model: SettingsViewModel func body(content: Content) -> some View { diff --git a/CodeEdit/Features/SplitView/EditorView.swift b/CodeEdit/Features/SplitView/EditorView.swift index 0484af347..9694e8b10 100644 --- a/CodeEdit/Features/SplitView/EditorView.swift +++ b/CodeEdit/Features/SplitView/EditorView.swift @@ -10,8 +10,7 @@ import SwiftUI struct EditorView: View { var tabgroup: TabGroup - @FocusState.Binding - var focus: TabGroupData? + @FocusState.Binding var focus: TabGroupData? @Environment(\.window) private var window diff --git a/CodeEdit/Features/StatusBar/Views/StatusBarIcon.swift b/CodeEdit/Features/StatusBar/Views/StatusBarIcon.swift index 534db13b8..7b817fbfd 100644 --- a/CodeEdit/Features/StatusBar/Views/StatusBarIcon.swift +++ b/CodeEdit/Features/StatusBar/Views/StatusBarIcon.swift @@ -69,8 +69,10 @@ struct IconButtonStyle: ButtonStyle { var isActive: Bool var font: Font var size: CGFloat? - @Environment(\.isEnabled) private var isEnabled: Bool - @Environment(\.colorScheme) private var colorScheme + @Environment(\.isEnabled) + private var isEnabled: Bool + @Environment(\.colorScheme) + private var colorScheme init(configuration: ButtonStyle.Configuration, isActive: Bool?, font: Font?, size: CGFloat?) { self.configuration = configuration diff --git a/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarBreakpointButton.swift b/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarBreakpointButton.swift index 8098edcd6..fb269d0fc 100644 --- a/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarBreakpointButton.swift +++ b/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarBreakpointButton.swift @@ -9,8 +9,7 @@ import SwiftUI import CodeEditSymbols struct StatusBarBreakpointButton: View { - @EnvironmentObject - private var model: DebugAreaViewModel + @EnvironmentObject private var model: DebugAreaViewModel var body: some View { Button { diff --git a/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarCursorLocationLabel.swift b/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarCursorLocationLabel.swift index 01de36c3d..76325bcc9 100644 --- a/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarCursorLocationLabel.swift +++ b/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarCursorLocationLabel.swift @@ -11,8 +11,7 @@ struct StatusBarCursorLocationLabel: View { @Environment(\.controlActiveState) private var controlActive - @EnvironmentObject - private var model: DebugAreaViewModel + @EnvironmentObject private var model: DebugAreaViewModel var body: some View { Text("Line: \(model.cursorLocation.line) Col: \(model.cursorLocation.column)") diff --git a/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarIndentSelector.swift b/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarIndentSelector.swift index 5ceb75a1d..fdae627cf 100644 --- a/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarIndentSelector.swift +++ b/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarIndentSelector.swift @@ -8,7 +8,8 @@ import SwiftUI struct StatusBarIndentSelector: View { - @AppSettings(\.textEditing.defaultTabWidth) var defaultTabWidth + @AppSettings(\.textEditing.defaultTabWidth) + var defaultTabWidth var body: some View { Menu { diff --git a/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarToggleDrawerButton.swift b/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarToggleDrawerButton.swift index ffc994def..0863e8695 100644 --- a/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarToggleDrawerButton.swift +++ b/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarToggleDrawerButton.swift @@ -8,8 +8,7 @@ import SwiftUI internal struct StatusBarToggleDrawerButton: View { - @EnvironmentObject - private var model: DebugAreaViewModel + @EnvironmentObject private var model: DebugAreaViewModel init() { CommandManager.shared.addCommand( diff --git a/CodeEdit/Features/StatusBar/Views/StatusBarView.swift b/CodeEdit/Features/StatusBar/Views/StatusBarView.swift index 060d4d6bd..04cdfaf6f 100644 --- a/CodeEdit/Features/StatusBar/Views/StatusBarView.swift +++ b/CodeEdit/Features/StatusBar/Views/StatusBarView.swift @@ -20,8 +20,7 @@ struct StatusBarView: View { @Environment(\.controlActiveState) private var controlActive - @EnvironmentObject - private var model: DebugAreaViewModel + @EnvironmentObject private var model: DebugAreaViewModel static let height = 28.0 diff --git a/CodeEdit/Features/Tabs/Models/TabManager.swift b/CodeEdit/Features/Tabs/Models/TabManager.swift index 6e474bb1c..d2ac6e2d1 100644 --- a/CodeEdit/Features/Tabs/Models/TabManager.swift +++ b/CodeEdit/Features/Tabs/Models/TabManager.swift @@ -12,12 +12,10 @@ import OrderedCollections class TabManager: ObservableObject { /// Collection of all the tabgroups. - @Published - var tabGroups: TabGroup + @Published var tabGroups: TabGroup /// The TabGroup with active focus. - @Published - var activeTabGroup: TabGroupData { + @Published var activeTabGroup: TabGroupData { didSet { activeTabGroupHistory.prepend { [weak oldValue] in oldValue } switchToActiveTabGroup() diff --git a/CodeEdit/Features/Tabs/TabGroup/TabGroupData.swift b/CodeEdit/Features/Tabs/TabGroup/TabGroupData.swift index 570158065..5c339a6ad 100644 --- a/CodeEdit/Features/Tabs/TabGroup/TabGroupData.swift +++ b/CodeEdit/Features/Tabs/TabGroup/TabGroupData.swift @@ -13,8 +13,7 @@ final class TabGroupData: ObservableObject, Identifiable { typealias Tab = CEWorkspaceFile /// Set of open tabs. - @Published - var tabs: OrderedSet = [] { + @Published var tabs: OrderedSet = [] { didSet { let change = tabs.symmetricDifference(oldValue) @@ -35,8 +34,7 @@ final class TabGroupData: ObservableObject, Identifiable { } /// The current offset in the history list. - @Published - var historyOffset: Int = 0 { + @Published var historyOffset: Int = 0 { didSet { let tab = history[historyOffset] @@ -52,15 +50,12 @@ final class TabGroupData: ObservableObject, Identifiable { } /// History of tab switching. - @Published - var history: Deque = [] + @Published var history: Deque = [] /// Currently selected tab. - @Published - var selected: Tab? + @Published var selected: Tab? - @Published - var temporaryTab: Tab? + @Published var temporaryTab: Tab? let id = UUID() diff --git a/CodeEdit/Features/Tabs/TabGroup/WorkspaceTabGroupView.swift b/CodeEdit/Features/Tabs/TabGroup/WorkspaceTabGroupView.swift index 726556976..a8ff3ea81 100644 --- a/CodeEdit/Features/Tabs/TabGroup/WorkspaceTabGroupView.swift +++ b/CodeEdit/Features/Tabs/TabGroup/WorkspaceTabGroupView.swift @@ -8,14 +8,11 @@ import SwiftUI struct WorkspaceTabGroupView: View { - @ObservedObject - var tabgroup: TabGroupData + @ObservedObject var tabgroup: TabGroupData - @FocusState.Binding - var focus: TabGroupData? + @FocusState.Binding var focus: TabGroupData? - @EnvironmentObject - private var tabManager: TabManager + @EnvironmentObject private var tabManager: TabManager var body: some View { VStack { diff --git a/CodeEdit/Features/Tabs/Views/TabBarContextMenu.swift b/CodeEdit/Features/Tabs/Views/TabBarContextMenu.swift index 64362e630..75b212437 100644 --- a/CodeEdit/Features/Tabs/Views/TabBarContextMenu.swift +++ b/CodeEdit/Features/Tabs/Views/TabBarContextMenu.swift @@ -23,13 +23,12 @@ struct TabBarContextMenu: ViewModifier { self.isTemporary = isTemporary } - @EnvironmentObject - var workspace: WorkspaceDocument + @EnvironmentObject var workspace: WorkspaceDocument - @EnvironmentObject - var tabs: TabGroupData + @EnvironmentObject var tabs: TabGroupData - @Environment(\.splitEditor) var splitEditor + @Environment(\.splitEditor) + var splitEditor private var item: CEWorkspaceFile private var isTemporary: Bool diff --git a/CodeEdit/Features/Tabs/Views/TabBarDivider.swift b/CodeEdit/Features/Tabs/Views/TabBarDivider.swift index dec863537..eb7b6ea8b 100644 --- a/CodeEdit/Features/Tabs/Views/TabBarDivider.swift +++ b/CodeEdit/Features/Tabs/Views/TabBarDivider.swift @@ -12,7 +12,8 @@ struct TabDivider: View { @Environment(\.colorScheme) var colorScheme - @AppSettings(\.general.tabBarStyle) var tabBarStyle + @AppSettings(\.general.tabBarStyle) + var tabBarStyle let width: CGFloat = 1 @@ -35,7 +36,8 @@ struct TabBarTopDivider: View { @Environment(\.colorScheme) var colorScheme - @AppSettings(\.general.tabBarStyle) var tabBarStyle + @AppSettings(\.general.tabBarStyle) + var tabBarStyle var body: some View { ZStack(alignment: .top) { @@ -56,7 +58,8 @@ struct TabBarBottomDivider: View { @Environment(\.colorScheme) var colorScheme - @AppSettings(\.general.tabBarStyle) var tabBarStyle + @AppSettings(\.general.tabBarStyle) + var tabBarStyle var body: some View { Rectangle() diff --git a/CodeEdit/Features/Tabs/Views/TabBarItemButtonStyle.swift b/CodeEdit/Features/Tabs/Views/TabBarItemButtonStyle.swift index 997f28d95..73b3b52d3 100644 --- a/CodeEdit/Features/Tabs/Views/TabBarItemButtonStyle.swift +++ b/CodeEdit/Features/Tabs/Views/TabBarItemButtonStyle.swift @@ -11,8 +11,7 @@ struct TabBarItemButtonStyle: ButtonStyle { @Environment(\.colorScheme) var colorScheme - @Binding - private var isPressing: Bool + @Binding private var isPressing: Bool init(isPressing: Binding) { self._isPressing = isPressing diff --git a/CodeEdit/Features/Tabs/Views/TabBarItemCloseButton.swift b/CodeEdit/Features/Tabs/Views/TabBarItemCloseButton.swift index 1744294fa..ff3ccbf71 100644 --- a/CodeEdit/Features/Tabs/Views/TabBarItemCloseButton.swift +++ b/CodeEdit/Features/Tabs/Views/TabBarItemCloseButton.swift @@ -13,19 +13,17 @@ struct TabBarItemCloseButton: View { var isDragging: Bool var closeAction: () -> Void - @Binding - var closeButtonGestureActive: Bool + @Binding var closeButtonGestureActive: Bool @Environment(\.colorScheme) var colorScheme - @AppSettings(\.general.tabBarStyle) var tabBarStyle + @AppSettings(\.general.tabBarStyle) + var tabBarStyle - @State - private var isPressingClose: Bool = false + @State private var isPressingClose: Bool = false - @State - private var isHoveringClose: Bool = false + @State private var isHoveringClose: Bool = false let buttonSize: CGFloat = 16 diff --git a/CodeEdit/Features/Tabs/Views/TabBarItemView.swift b/CodeEdit/Features/Tabs/Views/TabBarItemView.swift index 573fb9baa..f5a10fc3d 100644 --- a/CodeEdit/Features/Tabs/Views/TabBarItemView.swift +++ b/CodeEdit/Features/Tabs/Views/TabBarItemView.swift @@ -21,34 +21,30 @@ struct TabBarItemView: View { @Environment(\.isFullscreen) private var isFullscreen - @EnvironmentObject - private var tabManager: TabManager + @EnvironmentObject private var tabManager: TabManager - @AppSettings(\.general.tabBarStyle) var tabBarStyle + @AppSettings(\.general.tabBarStyle) + var tabBarStyle - @AppSettings(\.general.fileIconStyle) var fileIconStyle + @AppSettings(\.general.fileIconStyle) + var fileIconStyle /// Is cursor hovering over the entire tab. - @State - private var isHovering: Bool = false + @State private var isHovering: Bool = false /// Is cursor hovering over the close button. - @State - private var isHoveringClose: Bool = false + @State private var isHoveringClose: Bool = false /// Is entire tab being pressed. - @State - private var isPressing: Bool = false + @State private var isPressing: Bool = false /// Is close button being pressed. - @State - private var isPressingClose: Bool = false + @State private var isPressingClose: Bool = false /// A bool state for going-in animation. /// /// By default, this value is `false`. When the root view is appeared, it turns `true`. - @State - private var isAppeared: Bool = false + @State private var isAppeared: Bool = false /// The expected tab width in native tab bar style. private var expectedWidth: CGFloat @@ -60,11 +56,9 @@ struct TabBarItemView: View { private var onDragTabId: CEWorkspaceFile.ID? - @Binding - private var closeButtonGestureActive: Bool + @Binding private var closeButtonGestureActive: Bool - @EnvironmentObject - private var tabgroup: TabGroupData + @EnvironmentObject private var tabgroup: TabGroupData /// The item associated with the current tab. /// @@ -132,8 +126,7 @@ struct TabBarItemView: View { self._closeButtonGestureActive = closeButtonGestureActive } - @ViewBuilder - var content: some View { + @ViewBuilder var content: some View { HStack(spacing: 0.0) { TabDivider() .opacity( diff --git a/CodeEdit/Features/Tabs/Views/TabBarView.swift b/CodeEdit/Features/Tabs/Views/TabBarView.swift index 0ff4f3619..12cd15771 100644 --- a/CodeEdit/Features/Tabs/Views/TabBarView.swift +++ b/CodeEdit/Features/Tabs/Views/TabBarView.swift @@ -33,84 +33,71 @@ struct TabBarView: View { private var activeState /// The workspace document. - @EnvironmentObject - private var workspace: WorkspaceDocument + @EnvironmentObject private var workspace: WorkspaceDocument - @EnvironmentObject - private var tabManager: TabManager + @EnvironmentObject private var tabManager: TabManager - @EnvironmentObject - private var tabgroup: TabGroupData + @EnvironmentObject private var tabgroup: TabGroupData - @AppSettings(\.general.tabBarStyle) var tabBarStyle + @AppSettings(\.general.tabBarStyle) + var tabBarStyle /// The tab id of current dragging tab. /// /// It will be `nil` when there is no tab dragged currently. - @State - private var draggingTabId: TabID? + @State private var draggingTabId: TabID? - @State - private var onDragTabId: TabID? + @State private var onDragTabId: TabID? /// The start location of dragging. /// /// When there is no tab being dragged, it will be `nil`. /// - TODO: Check if I can use `value.startLocation` trustfully. - @State - private var draggingStartLocation: CGFloat? + @State private var draggingStartLocation: CGFloat? /// The last location of dragging. /// /// This is used to determine the dragging direction. /// - TODO: Check if I can use `value.translation` instead. - @State - private var draggingLastLocation: CGFloat? + @State private var draggingLastLocation: CGFloat? /// Current opened tabs. /// /// This is a copy of `workspace.selectionState.openedTabs`. /// I am making a copy of it because using state will hugely improve the dragging performance. /// Updating ObservedObject too often will generate lags. - @State - private var openedTabs: [TabID] = [] + @State private var openedTabs: [TabID] = [] /// A map of tab width. /// /// All width are measured dynamically (so it can also fit the Xcode tab bar style). /// This is used to be added on the offset of current dragging tab in order to make a smooth /// dragging experience. - @State - private var tabWidth: [TabID: CGFloat] = [:] + @State private var tabWidth: [TabID: CGFloat] = [:] /// A map of tab location (CGRect). /// /// All locations are measured dynamically. /// This is used to compute when we should swap two tabs based on current cursor location. - @State - private var tabLocations: [TabID: CGRect] = [:] + @State private var tabLocations: [TabID: CGRect] = [:] /// A map of tab offsets. /// /// This is used to determine the tab offset of every tab (by their tab id) while dragging. - @State - private var tabOffsets: [TabID: CGFloat] = [:] + @State private var tabOffsets: [TabID: CGFloat] = [:] /// The expected tab width in native tab bar style. /// /// This is computed by the total width of tab bar. It is updated automatically. - @State - private var expectedTabWidth: CGFloat = 0 + @State private var expectedTabWidth: CGFloat = 0 /// This state is used to detect if the mouse is hovering over tabs. /// If it is true, then we do not update the expected tab width immediately. - @State - private var isHoveringOverTabs: Bool = false + @State private var isHoveringOverTabs: Bool = false /// This state is used to detect if the dragging type should be changed from DragGesture to OnDrag. /// It is basically switched when vertical displacement is exceeding the threshold. - @State - private var shouldOnDrag: Bool = false + @State private var shouldOnDrag: Bool = false /// Is current `onDrag` over tabs? /// @@ -118,17 +105,14 @@ struct TabBarView: View { /// When it is false, then the dragging cursor is outside the tab bar, then we should shrink the space. /// /// - TODO: The change of this state is overall incorrect. Should move it into workspace state. - @State - private var isOnDragOverTabs: Bool = false + @State private var isOnDragOverTabs: Bool = false /// The last location of `onDrag`. /// /// It can be used on reordering algorithm of `onDrag` (detecting when should we switch two tabs). - @State - private var onDragLastLocation: CGPoint? + @State private var onDragLastLocation: CGPoint? - @State - private var closeButtonGestureActive: Bool = false + @State private var closeButtonGestureActive: Bool = false /// Update the expected tab width when corresponding UI state is updated. /// @@ -588,16 +572,11 @@ struct TabBarView: View { private struct TabBarItemOnDropDelegate: DropDelegate { private let currentTabId: TabID - @Binding - private var openedTabs: [TabID] - @Binding - private var onDragTabId: TabID? - @Binding - private var onDragLastLocation: CGPoint? - @Binding - private var isOnDragOverTabs: Bool - @Binding - private var tabWidth: [TabID: CGFloat] + @Binding private var openedTabs: [TabID] + @Binding private var onDragTabId: TabID? + @Binding private var onDragLastLocation: CGPoint? + @Binding private var isOnDragOverTabs: Bool + @Binding private var tabWidth: [TabID: CGFloat] public init( currentTabId: TabID, diff --git a/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView+Coordinator.swift b/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView+Coordinator.swift index 1f35e59fe..cf88289fa 100644 --- a/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView+Coordinator.swift +++ b/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView+Coordinator.swift @@ -11,8 +11,7 @@ import SwiftTerm extension TerminalEmulatorView { final class Coordinator: NSObject, LocalProcessTerminalViewDelegate { - @State - private var url: URL + @State private var url: URL public var onTitleChange: (_ title: String) -> Void diff --git a/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift b/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift index c59c535ca..37301314d 100644 --- a/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift +++ b/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift @@ -16,16 +16,16 @@ import SwiftTerm /// for use in SwiftUI. /// struct TerminalEmulatorView: NSViewRepresentable { - @AppSettings(\.terminal) var terminalSettings - @AppSettings(\.textEditing.font) var fontSettings + @AppSettings(\.terminal) + var terminalSettings + @AppSettings(\.textEditing.font) + var fontSettings - @StateObject - private var themeModel: ThemeModel = .shared + @StateObject private var themeModel: ThemeModel = .shared static var lastTerminal: [String: LocalProcessTerminalView] = [:] - @State - var terminal: LocalProcessTerminalView + @State var terminal: LocalProcessTerminalView private let systemFont: NSFont = .monospacedSystemFont(ofSize: 11, weight: .medium) diff --git a/CodeEdit/Features/Welcome/Views/WelcomeView.swift b/CodeEdit/Features/Welcome/Views/WelcomeView.swift index cf9f3ff41..2826e048f 100644 --- a/CodeEdit/Features/Welcome/Views/WelcomeView.swift +++ b/CodeEdit/Features/Welcome/Views/WelcomeView.swift @@ -13,22 +13,18 @@ struct WelcomeView: View { @Environment(\.colorScheme) var colorScheme - @AppSettings(\.general.reopenBehavior) var reopenBehavior + @AppSettings(\.general.reopenBehavior) + var reopenBehavior - @State - private var repoPath = "~/" + @State private var repoPath = "~/" - @State - var showGitClone = false + @State var showGitClone = false - @State - var showCheckoutBranch = false + @State var showCheckoutBranch = false - @State - var isHovering: Bool = false + @State var isHovering: Bool = false - @State - var isHoveringCloseButton: Bool = false + @State var isHoveringCloseButton: Bool = false private let openDocument: (URL?, @escaping () -> Void) -> Void private let newDocument: () -> Void diff --git a/CodeEdit/Features/Welcome/Views/WelcomeWindow.swift b/CodeEdit/Features/Welcome/Views/WelcomeWindow.swift index 045d7e8a8..b1e067c3a 100644 --- a/CodeEdit/Features/Welcome/Views/WelcomeWindow.swift +++ b/CodeEdit/Features/Welcome/Views/WelcomeWindow.swift @@ -29,8 +29,10 @@ struct WelcomeWindow: Scene { } struct ContentView: View { - @Environment(\.dismiss) var dismiss - @Environment(\.openWindow) var openWindow + @Environment(\.dismiss) + var dismiss + @Environment(\.openWindow) + var openWindow var body: some View { WelcomeWindowView(shellClient: currentWorld.shellClient) { url, opened in diff --git a/CodeEdit/Features/WindowCommands/ExtensionCommands.swift b/CodeEdit/Features/WindowCommands/ExtensionCommands.swift index b56182ca1..86dbd4d7e 100644 --- a/CodeEdit/Features/WindowCommands/ExtensionCommands.swift +++ b/CodeEdit/Features/WindowCommands/ExtensionCommands.swift @@ -11,7 +11,8 @@ import CodeEditKit struct ExtensionCommands: Commands { @FocusedObject var manager: ExtensionManager? - @Environment(\.openWindow) var openWindow + @Environment(\.openWindow) + var openWindow var body: some Commands { CommandMenu("Extensions") { diff --git a/CodeEdit/Features/WindowCommands/MainCommands.swift b/CodeEdit/Features/WindowCommands/MainCommands.swift index d93346c67..19ed7d78b 100644 --- a/CodeEdit/Features/WindowCommands/MainCommands.swift +++ b/CodeEdit/Features/WindowCommands/MainCommands.swift @@ -9,8 +9,8 @@ import SwiftUI import Sparkle struct MainCommands: Commands { - - @Environment(\.openWindow) var openWindow + @Environment(\.openWindow) + var openWindow var body: some Commands { CommandGroup(replacing: .appInfo) { diff --git a/CodeEdit/Features/WindowCommands/ViewCommands.swift b/CodeEdit/Features/WindowCommands/ViewCommands.swift index 5e23b923d..c4fd2ac96 100644 --- a/CodeEdit/Features/WindowCommands/ViewCommands.swift +++ b/CodeEdit/Features/WindowCommands/ViewCommands.swift @@ -8,8 +8,10 @@ import SwiftUI struct ViewCommands: Commands { - @AppSettings(\.textEditing.font.size) var editorFontSize - @AppSettings(\.terminal.font.size) var terminalFontSize + @AppSettings(\.textEditing.font.size) + var editorFontSize + @AppSettings(\.terminal.font.size) + var terminalFontSize @State var windowController: CodeEditWindowController? diff --git a/CodeEdit/Features/WindowCommands/WindowCommands.swift b/CodeEdit/Features/WindowCommands/WindowCommands.swift index 45045918e..436f92a67 100644 --- a/CodeEdit/Features/WindowCommands/WindowCommands.swift +++ b/CodeEdit/Features/WindowCommands/WindowCommands.swift @@ -9,7 +9,8 @@ import SwiftUI struct WindowCommands: Commands { - @Environment(\.openWindow) var openWindow + @Environment(\.openWindow) + var openWindow var body: some Commands { CommandGroup(after: .windowArrangement) { diff --git a/CodeEdit/WindowObserver.swift b/CodeEdit/WindowObserver.swift index 55d4189a5..b37c04ecd 100644 --- a/CodeEdit/WindowObserver.swift +++ b/CodeEdit/WindowObserver.swift @@ -11,15 +11,14 @@ struct WindowObserver: View { var window: NSWindow - @ViewBuilder - var content: Content + @ViewBuilder var content: Content /// The fullscreen state of the NSWindow. /// This will be passed into all child views as an environment variable. - @State - private var isFullscreen = false + @State private var isFullscreen = false - @AppSettings(\.general.tabBarStyle) var tabBarStyle + @AppSettings(\.general.tabBarStyle) + var tabBarStyle @State var modifierFlags: NSEvent.ModifierFlags = [] diff --git a/CodeEdit/WorkspaceView.swift b/CodeEdit/WorkspaceView.swift index bc2c613c8..9fb153b93 100644 --- a/CodeEdit/WorkspaceView.swift +++ b/CodeEdit/WorkspaceView.swift @@ -13,39 +13,32 @@ struct WorkspaceView: View { let tabBarHeight = 28.0 private var path: String = "" - @EnvironmentObject - private var workspace: WorkspaceDocument + @EnvironmentObject private var workspace: WorkspaceDocument - @EnvironmentObject - private var tabManager: TabManager + @EnvironmentObject private var tabManager: TabManager - @EnvironmentObject - private var debugAreaModel: DebugAreaViewModel + @EnvironmentObject private var debugAreaModel: DebugAreaViewModel @Environment(\.window) private var window private var keybindings: KeybindingManager = .shared - @State - private var showingAlert = false + @State private var showingAlert = false @Environment(\.colorScheme) private var colorScheme - @AppSettings(\.theme.matchAppearance) var matchAppearance + @AppSettings(\.theme.matchAppearance) + var matchAppearance - @StateObject - private var themeModel: ThemeModel = .shared + @StateObject private var themeModel: ThemeModel = .shared - @State - private var terminalCollapsed = true + @State private var terminalCollapsed = true - @State - private var editorCollapsed = false + @State private var editorCollapsed = false - @FocusState - var focusedEditor: TabGroupData? + @FocusState var focusedEditor: TabGroupData? var body: some View { if workspace.workspaceFileManager != nil { diff --git a/OpenWithCodeEdit/FinderSync.swift b/OpenWithCodeEdit/FinderSync.swift index 166994c30..56463a5be 100644 --- a/OpenWithCodeEdit/FinderSync.swift +++ b/OpenWithCodeEdit/FinderSync.swift @@ -43,7 +43,8 @@ class CEOpenWith: FIFinderSync { /// Open in CodeEdit (menu) action /// - Parameter sender: sender - @objc func openInCodeEditAction(_ sender: AnyObject?) { + @objc + func openInCodeEditAction(_ sender: AnyObject?) { guard let items = FIFinderSyncController.default().selectedItemURLs(), let defaults = UserDefaults.init(suiteName: "app.codeedit.CodeEdit.shared") else { return From f6a1f8503a9aa4e9cc450da5bddd53754e0f3676 Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Tue, 20 Jun 2023 17:08:16 +0200 Subject: [PATCH 2/7] Update DebugAreaViewModel.swift --- .../Features/DebugArea/ViewModels/DebugAreaViewModel.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CodeEdit/Features/DebugArea/ViewModels/DebugAreaViewModel.swift b/CodeEdit/Features/DebugArea/ViewModels/DebugAreaViewModel.swift index 62a7eaad3..2d1a25192 100644 --- a/CodeEdit/Features/DebugArea/ViewModels/DebugAreaViewModel.swift +++ b/CodeEdit/Features/DebugArea/ViewModels/DebugAreaViewModel.swift @@ -20,11 +20,9 @@ class DebugAreaViewModel: ObservableObject { /// Returns the current location of the cursor in an editing view @Published var cursorLocation: CursorLocation = .init(line: 1, column: 1) // Implementation needed!! - @Published - var terminals: [DebugAreaTerminal] = [] + @Published var terminals: [DebugAreaTerminal] = [] - @Published - var selectedTerminals: Set = [] + @Published var selectedTerminals: Set = [] /// Indicates whether debugger is collapse or not @Published var isCollapsed: Bool = false From afe21c2e3f510de7a1309b75b69d157039d243a4 Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Tue, 20 Jun 2023 17:09:29 +0200 Subject: [PATCH 3/7] Update ViewCommands.swift --- CodeEdit/Features/WindowCommands/ViewCommands.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CodeEdit/Features/WindowCommands/ViewCommands.swift b/CodeEdit/Features/WindowCommands/ViewCommands.swift index 9866cf724..6bfe0a60e 100644 --- a/CodeEdit/Features/WindowCommands/ViewCommands.swift +++ b/CodeEdit/Features/WindowCommands/ViewCommands.swift @@ -20,9 +20,11 @@ struct ViewCommands: Commands { private let documentController: CodeEditDocumentController = CodeEditDocumentController() private let statusBarViewModel: DebugAreaViewModel = DebugAreaViewModel() - @FocusedBinding(\.navigationSplitViewVisibility) var navigationSplitViewVisibility + @FocusedBinding(\.navigationSplitViewVisibility) + var navigationSplitViewVisibility - @FocusedBinding(\.inspectorVisibility) var inspectorVisibility + @FocusedBinding(\.inspectorVisibility) + var inspectorVisibility var navigatorCollapsed: Bool { windowController?.navigatorCollapsed ?? false From 43eb9712644ad8b78ec2a6295039663687f3f8e4 Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Tue, 20 Jun 2023 17:10:21 +0200 Subject: [PATCH 4/7] Update CodeEditApp.swift --- CodeEdit/CodeEditApp.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CodeEdit/CodeEditApp.swift b/CodeEdit/CodeEditApp.swift index 3cea4b7f2..fe3d554af 100644 --- a/CodeEdit/CodeEditApp.swift +++ b/CodeEdit/CodeEditApp.swift @@ -13,7 +13,8 @@ struct CodeEditApp: App { @NSApplicationDelegateAdaptor var appdelegate: AppDelegate @ObservedObject var settings = Settings.shared - @Environment(\.openWindow) var openWindow + @Environment(\.openWindow) + var openWindow let updater: SoftwareUpdater = SoftwareUpdater() From e1b1d1a5a79be10b5d134b1db55e1c44a7db694c Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Tue, 20 Jun 2023 17:11:02 +0200 Subject: [PATCH 5/7] Update FeatureFlagsSettingsView.swift --- .../Settings/Pages/FeatureFlags/FeatureFlagsSettingsView.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CodeEdit/Features/Settings/Pages/FeatureFlags/FeatureFlagsSettingsView.swift b/CodeEdit/Features/Settings/Pages/FeatureFlags/FeatureFlagsSettingsView.swift index 55e5d58fa..ddf222b4b 100644 --- a/CodeEdit/Features/Settings/Pages/FeatureFlags/FeatureFlagsSettingsView.swift +++ b/CodeEdit/Features/Settings/Pages/FeatureFlags/FeatureFlagsSettingsView.swift @@ -9,7 +9,8 @@ import SwiftUI struct FeatureFlagsSettingsView: View { - @AppSettings(\.featureFlags.useNewWindowingSystem) var useNewWindowingSystem + @AppSettings(\.featureFlags.useNewWindowingSystem) + var useNewWindowingSystem var body: some View { Form { From 26e0f6978734e0fe937414c6a4632a4e09729372 Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Tue, 20 Jun 2023 19:30:27 +0200 Subject: [PATCH 6/7] fix swiftlint warnings --- .swiftlint.yml | 1 + CodeEdit/Features/CodeFile/CodeFile.swift | 12 ++++-------- .../InspectorSidebar/Views/FileInspectorView.swift | 6 ++---- .../Views/HistoryInspectorView.swift | 6 ++---- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index c0d87c6e0..22f7378f6 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -16,6 +16,7 @@ identifier_name: excluded: - CodeEditModules/.build # Where Swift Package Manager checks out dependency sources - DerivedData + opt_in_rules: - attributes - empty_count diff --git a/CodeEdit/Features/CodeFile/CodeFile.swift b/CodeEdit/Features/CodeFile/CodeFile.swift index ae7e57e8e..aa9f7cbde 100644 --- a/CodeEdit/Features/CodeFile/CodeFile.swift +++ b/CodeEdit/Features/CodeFile/CodeFile.swift @@ -25,20 +25,16 @@ final class CodeFileDocument: NSDocument, ObservableObject, QLPreviewItem { @Published var content = "" /// Used to override detected languages. - @Published - var language: CodeLanguage? + @Published var language: CodeLanguage? /// Document-specific overriden indent option. - @Published - var indentOption: SettingsData.TextEditingSettings.IndentOption? + @Published var indentOption: SettingsData.TextEditingSettings.IndentOption? /// Document-specific overriden tab width. - @Published - var defaultTabWidth: Int? + @Published var defaultTabWidth: Int? /// Document-specific overriden line wrap preference. - @Published - var wrapLines: Bool? + @Published var wrapLines: Bool? /* This is the main type of the document. diff --git a/CodeEdit/Features/InspectorSidebar/Views/FileInspectorView.swift b/CodeEdit/Features/InspectorSidebar/Views/FileInspectorView.swift index d270c482e..e84533cc0 100644 --- a/CodeEdit/Features/InspectorSidebar/Views/FileInspectorView.swift +++ b/CodeEdit/Features/InspectorSidebar/Views/FileInspectorView.swift @@ -73,8 +73,7 @@ struct FileInspectorView: View { } } - @ViewBuilder - private var fileNameField: some View { + @ViewBuilder private var fileNameField: some View { if let file { TextField("Name", text: $fileName) .background( @@ -103,8 +102,7 @@ struct FileInspectorView: View { } } - @ViewBuilder - private var fileType: some View { + @ViewBuilder private var fileType: some View { Picker( "Type", selection: $language diff --git a/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorView.swift b/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorView.swift index f5ff2f136..9acbb19d4 100644 --- a/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorView.swift +++ b/CodeEdit/Features/InspectorSidebar/Views/HistoryInspectorView.swift @@ -7,11 +7,9 @@ import SwiftUI struct HistoryInspectorView: View { - @EnvironmentObject - private var workspace: WorkspaceDocument + @EnvironmentObject private var workspace: WorkspaceDocument - @EnvironmentObject - private var tabManager: TabManager + @EnvironmentObject private var tabManager: TabManager @ObservedObject private var model: HistoryInspectorModel From d44cd83349c033bb7895c78915fa59d9de0976e5 Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Wed, 21 Jun 2023 22:28:47 +0200 Subject: [PATCH 7/7] Delete FileInspectorModel.swift --- .../Models/FileInspectorModel.swift | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 CodeEdit/Features/InspectorSidebar/Models/FileInspectorModel.swift diff --git a/CodeEdit/Features/InspectorSidebar/Models/FileInspectorModel.swift b/CodeEdit/Features/InspectorSidebar/Models/FileInspectorModel.swift deleted file mode 100644 index d032c7449..000000000 --- a/CodeEdit/Features/InspectorSidebar/Models/FileInspectorModel.swift +++ /dev/null @@ -1,79 +0,0 @@ -// -// FileInspectorModel.swift -// CodeEdit -// -// Created by Nanashi Li on 2022/04/17. -// - -import SwiftUI - -public final class FileInspectorModel: ObservableObject { - - /// The base URL of the workspace - private(set) var workspaceURL: URL - - @Published var fileTypeSelection: LanguageType.ID = "swift" - @Published var fileURL: String = "" - @Published var fileName: String = "" - - @Published var locationSelection: FileLocation.ID = "relative_group" - @Published var textEncodingSelection: TextEncoding.ID = "utf8" - @Published var lineEndingsSelection: LineEndings.ID = "macos" - @Published var indentUsingSelection: IndentUsing.ID = "spaces" - - @Published var languageTypeObjCList = FileTypeList.init().languageTypeObjCList - @Published var sourcecodeCList = FileTypeList.init().sourcecodeCList - @Published var sourcecodeCPlusList = FileTypeList.init().sourcecodeCPlusList - @Published var sourcecodeSwiftList = FileTypeList.init().sourcecodeSwiftList - @Published var sourcecodeAssemblyList = FileTypeList.init().sourcecodeAssemblyList - @Published var sourcecodeScriptList = FileTypeList.init().sourcecodeScriptList - @Published var sourcecodeVariousList = FileTypeList.init().sourcecodeVariousList - @Published var propertyList = FileTypeList.init().propertyList - @Published var shellList = FileTypeList.init().shellList - @Published var machOList = FileTypeList.init().machOList - @Published var textList = FileTypeList.init().textList - @Published var audioList = FileTypeList.init().audioList - @Published var imageList = FileTypeList.init().imageList - @Published var videoList = FileTypeList.init().videoList - @Published var archiveList = FileTypeList.init().archiveList - @Published var otherList = FileTypeList.init().otherList - - @Published var locationList = [ - FileLocation(name: "Absolute Path", id: "absolute"), - FileLocation(name: "Relative to Group", id: "relative_group"), - FileLocation(name: "Relative to Project", id: "relative_project"), - FileLocation(name: "Relative to Developer Directory", id: "relative_developer_dir"), - FileLocation(name: "Relative to Build Projects", id: "relative_build_projects"), - FileLocation(name: "Relative to SDK", id: "relative_sdk") - ] - - @Published var textEncodingList = [ - TextEncoding(name: "Unicode (UTF-8)", id: "utf8"), - TextEncoding(name: "Unicode (UTF-16)", id: "utf16"), - TextEncoding(name: "Unicode (UTF-16BE)", id: "utf16_be"), - TextEncoding(name: "Unicode (UTF-16LE)", id: "utf16_le") - ] - - @Published var lineEndingsList = [ - LineEndings(name: "macOS / Unix (LF)", id: "macos"), - LineEndings(name: "Classic macOS (CR)", id: "classic"), - LineEndings(name: "Windows (CRLF)", id: "windows") - ] - - @Published var indentUsingList = [ - IndentUsing(name: "Spaces", id: "spaces"), - IndentUsing(name: "Tabs", id: "tabs") - ] - - @Published var tabWidth: Int = 4 - - @Published var indentWidth: Int = 4 - - @Published var wrapLines: Bool = true - - public init(workspaceURL: URL, fileURL: String) { - self.workspaceURL = workspaceURL - self.fileURL = fileURL - self.fileName = (fileURL as NSString).lastPathComponent - } -}