mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Omit verbose @MainActor
This commit is contained in:
parent
b180902ab1
commit
b19699294b
@ -114,9 +114,7 @@ private struct ColorCodePanelAccessory: View {
|
||||
if let colorCode, let color = NSColor(colorCode: colorCode, type: &type), let type {
|
||||
self.colorCode = colorCode
|
||||
self.type = type.rawValue
|
||||
Task { @MainActor in
|
||||
panel.color = color
|
||||
}
|
||||
panel.color = color
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +163,7 @@ private struct ColorCodePanelAccessory: View {
|
||||
// MARK: Private Methods
|
||||
|
||||
/// Inserts the color code to the selection of the frontmost document.
|
||||
@MainActor private func submit() {
|
||||
private func submit() {
|
||||
|
||||
self.apply(colorCode: self.colorCode)
|
||||
|
||||
@ -179,7 +177,7 @@ private struct ColorCodePanelAccessory: View {
|
||||
/// Sets the color representing the given code to the color panel and selects the corresponding color code type.
|
||||
///
|
||||
/// - Parameter colorCode: The color code of the color to set.
|
||||
@MainActor private func apply(colorCode: String) {
|
||||
private func apply(colorCode: String) {
|
||||
|
||||
var type: ColorCodeType?
|
||||
guard
|
||||
@ -195,7 +193,7 @@ private struct ColorCodePanelAccessory: View {
|
||||
/// Converts the color code to the specified code type.
|
||||
///
|
||||
/// - Parameter rawValue: The rawValue of ColorCodeType.
|
||||
@MainActor private func apply(type rawValue: Int) {
|
||||
private func apply(type rawValue: Int) {
|
||||
|
||||
guard
|
||||
let type = ColorCodeType(rawValue: rawValue),
|
||||
|
@ -146,7 +146,7 @@ struct CommandBarView: View {
|
||||
|
||||
|
||||
/// Performs the selected command and closes the view.
|
||||
@MainActor private func perform() {
|
||||
private func perform() {
|
||||
|
||||
// first close the command bar and then take the action
|
||||
// so that the action is delivered to the correct (first) responder.
|
||||
|
@ -92,7 +92,7 @@ struct CustomSurroundView: View {
|
||||
// MARK: Private Methods
|
||||
|
||||
/// Submits the current input.
|
||||
@MainActor private func submit() {
|
||||
private func submit() {
|
||||
|
||||
self.parent?.commitEditing()
|
||||
|
||||
|
@ -73,7 +73,7 @@ struct CustomTabWidthView: View {
|
||||
// MARK: Private Methods
|
||||
|
||||
/// Submits the current input.
|
||||
@MainActor private func submit() {
|
||||
private func submit() {
|
||||
|
||||
self.completionHandler(self.value)
|
||||
self.parent?.dismiss(nil)
|
||||
|
@ -26,7 +26,7 @@
|
||||
import SwiftUI
|
||||
import StoreKit
|
||||
|
||||
@MainActor struct DonationSettingsView: View {
|
||||
struct DonationSettingsView: View {
|
||||
|
||||
#if SPARKLE
|
||||
var isInAppPurchaseAvailable = false
|
||||
@ -210,7 +210,7 @@ private struct OnetimeProductViewStyle: ProductViewStyle {
|
||||
.accessibilityLabel(String(localized: "Quantity", table: "DonationSettings", comment: "accessibility label for item quantity stepper"))
|
||||
Spacer()
|
||||
Button((product.price * Decimal(self.quantity)).formatted(product.priceFormatStyle)) {
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
do {
|
||||
_ = try await self.purchase(product, options: [.quantity(self.quantity)])
|
||||
} catch {
|
||||
|
@ -8,7 +8,7 @@
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// © 2022-2023 1024jp
|
||||
// © 2022-2024 1024jp
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -130,7 +130,7 @@ final class DraggableHostingView<Content>: NSHostingView<Content> where Content:
|
||||
// MARK: Private Methods
|
||||
|
||||
/// The area the receiver located in the superview.
|
||||
@MainActor private var preferredEdge: Edge? {
|
||||
private var preferredEdge: Edge? {
|
||||
|
||||
self.superview.flatMap { superview in
|
||||
Edge(horizontal: superview.frame.width/2 < self.frame.midX ? .right : .left,
|
||||
@ -140,7 +140,7 @@ final class DraggableHostingView<Content>: NSHostingView<Content> where Content:
|
||||
|
||||
|
||||
/// Keeps position to be inside of the parent frame.
|
||||
@MainActor private func adjustPosition() {
|
||||
private func adjustPosition() {
|
||||
|
||||
guard let superFrame = self.superview?.frame else { return assertionFailure() }
|
||||
|
||||
|
@ -159,9 +159,7 @@ final class EditorTextViewController: NSViewController, NSServicesMenuRequestor,
|
||||
super.restoreState(with: coder)
|
||||
|
||||
if coder.decodeBool(forKey: SerializationKey.showsAdvancedCounter) {
|
||||
Task { @MainActor in
|
||||
self.showAdvancedCharacterCounter()
|
||||
}
|
||||
self.showAdvancedCharacterCounter()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ struct FindPanelButtonView: View {
|
||||
/// Send a text finder action message to the legacy responder-chain.
|
||||
///
|
||||
/// - Parameter action: The `TextFinder.Action` to perform.
|
||||
@MainActor private func performAction(_ action: TextFinder.Action) {
|
||||
private func performAction(_ action: TextFinder.Action) {
|
||||
|
||||
// create a dummy sender for tag
|
||||
let sender = NSControl()
|
||||
|
@ -240,7 +240,7 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {
|
||||
/// Updates the result count in the input fields.
|
||||
///
|
||||
/// - Parameter result: The find/replace result or `nil` to clear.
|
||||
@MainActor private func update(result: TextFindResult?) {
|
||||
private func update(result: TextFindResult?) {
|
||||
|
||||
switch result {
|
||||
case .found:
|
||||
@ -257,14 +257,14 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {
|
||||
|
||||
|
||||
/// Updates the find history menu.
|
||||
@MainActor private func updateFindHistoryMenu() {
|
||||
private func updateFindHistoryMenu() {
|
||||
|
||||
self.buildHistoryMenu(self.findHistoryMenu!, defaultsKey: .findHistory, action: #selector(selectFindHistory))
|
||||
}
|
||||
|
||||
|
||||
/// Updates the replace history menu.
|
||||
@MainActor private func updateReplaceHistoryMenu() {
|
||||
private func updateReplaceHistoryMenu() {
|
||||
|
||||
self.buildHistoryMenu(self.replaceHistoryMenu!, defaultsKey: .replaceHistory, action: #selector(selectReplaceHistory))
|
||||
}
|
||||
@ -276,7 +276,7 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {
|
||||
/// - menu: The menu to update the content.
|
||||
/// - key: The default key for the history.
|
||||
/// - action: The action selector for menu items.
|
||||
@MainActor private func buildHistoryMenu(_ menu: NSMenu, defaultsKey key: DefaultKey<[String]>, action: Selector) {
|
||||
private func buildHistoryMenu(_ menu: NSMenu, defaultsKey key: DefaultKey<[String]>, action: Selector) {
|
||||
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
@ -299,7 +299,7 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {
|
||||
/// Updates the find result message on the input field.
|
||||
///
|
||||
/// - Parameter message: The message to display in the input field, or `nil` to clear.
|
||||
@MainActor private func updateFoundMessage(_ message: String?) {
|
||||
private func updateFoundMessage(_ message: String?) {
|
||||
|
||||
self.applyResult(message: message, textField: self.findResultField!, textView: self.findTextView!)
|
||||
}
|
||||
@ -308,7 +308,7 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {
|
||||
/// Updates the replacement result message on the input field.
|
||||
///
|
||||
/// - Parameter message: The message to display in the input field, or `nil` to clear.
|
||||
@MainActor private func updateReplacedMessage(_ message: String?) {
|
||||
private func updateReplacedMessage(_ message: String?) {
|
||||
|
||||
self.applyResult(message: message, textField: self.replacementResultField!, textView: self.replacementTextView!)
|
||||
}
|
||||
@ -320,7 +320,7 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {
|
||||
/// - message: The localized message to display.
|
||||
/// - textField: The text field displaying the message.
|
||||
/// - textView: The input text view where shows the message.
|
||||
@MainActor private func applyResult(message: String?, textField: NSTextField, textView: NSTextView) {
|
||||
private func applyResult(message: String?, textField: NSTextField, textView: NSTextView) {
|
||||
|
||||
textField.isHidden = (message == nil)
|
||||
textField.stringValue = message ?? ""
|
||||
|
@ -38,7 +38,7 @@ final class FindPanelResultViewController: NSHostingController<FindPanelResultVi
|
||||
}
|
||||
|
||||
|
||||
@MainActor required dynamic init?(coder: NSCoder) {
|
||||
required dynamic init?(coder: NSCoder) {
|
||||
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
@ -156,7 +156,7 @@ struct FindPanelResultView: View {
|
||||
|
||||
// MARK: Private Methods
|
||||
|
||||
@MainActor private var message: String {
|
||||
private var message: String {
|
||||
|
||||
let documentName = self.model.target?.documentName ?? "Unknown" // This should never be nil.
|
||||
|
||||
@ -171,7 +171,7 @@ struct FindPanelResultView: View {
|
||||
/// Selects the match in the target text view.
|
||||
///
|
||||
/// - Parameter id: The identifier of the match to select.
|
||||
@MainActor private func selectMatch(_ id: Match.ID?) {
|
||||
private func selectMatch(_ id: Match.ID?) {
|
||||
|
||||
// abandon if text becomes shorter than range to select
|
||||
guard
|
||||
|
@ -69,7 +69,7 @@ struct GoToLineView: View {
|
||||
// MARK: Private Methods
|
||||
|
||||
/// Submits the current input.
|
||||
@MainActor private func submit() {
|
||||
private func submit() {
|
||||
|
||||
guard
|
||||
self.completionHandler(self.lineRange)
|
||||
|
@ -182,7 +182,7 @@ private extension IncompatibleCharactersView.Model {
|
||||
///
|
||||
/// - Returns: An array of Item.
|
||||
/// - Throws: `CancellationError`
|
||||
@MainActor private func scan() async throws -> [ValueRange<IncompatibleCharacter>] {
|
||||
private func scan() async throws -> [ValueRange<IncompatibleCharacter>] {
|
||||
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
@ -205,7 +205,7 @@ private extension IncompatibleCharactersView.Model {
|
||||
/// Update markup in the editors.
|
||||
///
|
||||
/// - Parameter items: The new incompatible characters.
|
||||
@MainActor private func updateMarkup(_ items: [ValueRange<IncompatibleCharacter>]) {
|
||||
private func updateMarkup(_ items: [ValueRange<IncompatibleCharacter>]) {
|
||||
|
||||
if !self.items.isEmpty {
|
||||
self.document?.textStorage.clearAllMarkup()
|
||||
|
@ -102,7 +102,7 @@ struct InconsistentLineEndingsView: View {
|
||||
/// Selects correspondence range of the item in the editor.
|
||||
///
|
||||
/// - Parameter id: The `id` of the item to select.
|
||||
@MainActor private func selectItem(id: Item.ID?) {
|
||||
private func selectItem(id: Item.ID?) {
|
||||
|
||||
guard
|
||||
let item = self.items[id: id],
|
||||
|
@ -35,7 +35,7 @@ extension NSTextView {
|
||||
/// - inSelection: Whether find string only in selectedRanges.
|
||||
/// - Returns: A result message.
|
||||
/// - Throws: `CancellationError`
|
||||
@MainActor final func highlight(_ definition: MultipleReplace, inSelection: Bool) async throws -> String {
|
||||
final func highlight(_ definition: MultipleReplace, inSelection: Bool) async throws -> String {
|
||||
|
||||
self.isEditable = false
|
||||
defer { self.isEditable = true }
|
||||
@ -92,7 +92,7 @@ extension NSTextView {
|
||||
/// - inSelection: Whether find string only in selectedRanges.
|
||||
/// - Returns: A result message.
|
||||
/// - Throws: `CancellationError`
|
||||
@MainActor final func replaceAll(_ definition: MultipleReplace, inSelection: Bool) async throws -> String {
|
||||
final func replaceAll(_ definition: MultipleReplace, inSelection: Bool) async throws -> String {
|
||||
|
||||
self.isEditable = false
|
||||
defer { self.isEditable = true }
|
||||
|
@ -8,7 +8,7 @@
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// © 2018-2023 1024jp
|
||||
// © 2018-2024 1024jp
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -34,7 +34,7 @@ extension NSTextView {
|
||||
/// - enabled: If true, parse and highlight, otherwise just remove the current highlight.
|
||||
/// - Returns: Whether the content is not invalid.
|
||||
@discardableResult
|
||||
@MainActor final func highlightAsRegularExpressionPattern(mode: RegularExpressionParseMode, enabled: Bool = true) -> Bool {
|
||||
final func highlightAsRegularExpressionPattern(mode: RegularExpressionParseMode, enabled: Bool = true) -> Bool {
|
||||
|
||||
guard
|
||||
let layoutManager = self.textLayoutManager
|
||||
@ -71,7 +71,7 @@ extension NSTextView {
|
||||
/// - mode: Parse mode of regular expression.
|
||||
/// - enabled: If true, parse and highlight, otherwise just remove the current highlight.
|
||||
/// - Returns: Whether the content is not invalid.
|
||||
@MainActor private func highlightAsRegularExpressionPatternWithLegacyTextKit(mode: RegularExpressionParseMode, enabled: Bool = true) -> Bool {
|
||||
private func highlightAsRegularExpressionPatternWithLegacyTextKit(mode: RegularExpressionParseMode, enabled: Bool = true) -> Bool {
|
||||
|
||||
guard let layoutManager = self.layoutManager else { assertionFailure(); return false }
|
||||
|
||||
|
@ -144,7 +144,7 @@ private struct OutlineNavigationView: View {
|
||||
|
||||
// MARK: Private Methods
|
||||
|
||||
@ViewBuilder @MainActor private func previousButton(systemImage: String) -> some View {
|
||||
@ViewBuilder private func previousButton(systemImage: String) -> some View {
|
||||
|
||||
Button {
|
||||
self.navigator.selectPreviousItem()
|
||||
@ -161,7 +161,7 @@ private struct OutlineNavigationView: View {
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder @MainActor private func nextButton(systemImage: String) -> some View {
|
||||
@ViewBuilder private func nextButton(systemImage: String) -> some View {
|
||||
|
||||
Button {
|
||||
self.navigator.selectNextItem()
|
||||
|
@ -168,7 +168,7 @@ struct PatternSortView: View {
|
||||
|
||||
|
||||
/// Submits the current input.
|
||||
@MainActor private func submit() {
|
||||
private func submit() {
|
||||
|
||||
guard
|
||||
self.parent?.commitEditing() == true
|
||||
|
@ -64,7 +64,7 @@ struct SyntaxEditView: View {
|
||||
weak var parent: NSHostingController<Self>?
|
||||
|
||||
|
||||
@MainActor private static var viewSize = CGSize(width: 680, height: 525)
|
||||
private static var viewSize = CGSize(width: 680, height: 525)
|
||||
|
||||
@State private var name: String = ""
|
||||
@State private var message: String?
|
||||
@ -228,7 +228,7 @@ struct SyntaxEditView: View {
|
||||
// MARK: Private Methods
|
||||
|
||||
/// Submits the syntax if it is valid.
|
||||
@MainActor private func submit() {
|
||||
private func submit() {
|
||||
|
||||
// syntax name validation
|
||||
self.name = self.name.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
@ -257,7 +257,7 @@ struct SyntaxEditView: View {
|
||||
|
||||
|
||||
/// Restores the current settings in editor to the user default.
|
||||
@MainActor private func restore() {
|
||||
private func restore() {
|
||||
|
||||
guard
|
||||
self.isBundled,
|
||||
|
@ -373,7 +373,7 @@ struct TextFindAllResult {
|
||||
/// Performs multiple replacement with a specific replacement definition.
|
||||
///
|
||||
/// - Parameter name: The name of the multiple replacement definition.
|
||||
@MainActor private func multiReplaceAll(name: String) {
|
||||
private func multiReplaceAll(name: String) {
|
||||
|
||||
guard let definition = try? ReplacementManager.shared.setting(name: name) else { return assertionFailure() }
|
||||
|
||||
|
@ -115,7 +115,7 @@ struct UnicodeInputView: View {
|
||||
|
||||
|
||||
/// Inputs Unicode character to the parent text view.
|
||||
@MainActor private func submit() {
|
||||
private func submit() {
|
||||
|
||||
guard let character = self.character else { return NSSound.beep() }
|
||||
|
||||
|
@ -167,7 +167,7 @@ private enum NewFeature: CaseIterable {
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder var supplementalView: some View {
|
||||
@MainActor @ViewBuilder var supplementalView: some View {
|
||||
|
||||
switch self {
|
||||
case .donation:
|
||||
@ -178,9 +178,7 @@ private enum NewFeature: CaseIterable {
|
||||
.fixedSize()
|
||||
#else
|
||||
Button(String(localized: "Open Donation Settings", table: "WhatsNew")) {
|
||||
Task { @MainActor in
|
||||
SettingsWindowController.shared.openPane(.donation)
|
||||
}
|
||||
SettingsWindowController.shared.openPane(.donation)
|
||||
}
|
||||
.buttonStyle(.capsule)
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user