mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-19 07:07:18 +03:00
Remove parentheses for single arg in closure
This commit is contained in:
parent
098608d2ec
commit
e497473a48
@ -92,7 +92,7 @@ import SwiftUI
|
||||
.receive(on: DispatchQueue.main)
|
||||
.compactMap { [weak self] in self?.textView.selectedStrings }
|
||||
.receive(on: DispatchQueue.global())
|
||||
.map { [unowned self] (strings) in
|
||||
.map { [unowned self] strings in
|
||||
strings
|
||||
.map { $0.count(options: self.setting.options) }
|
||||
.reduce(0) { (total, count) in
|
||||
|
@ -138,7 +138,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
SyntaxManager.shared.$settingNames
|
||||
.map { $0.map { NSMenuItem(title: $0, action: #selector((any SyntaxChanging).changeSyntax), keyEquivalent: "") } }
|
||||
.receive(on: RunLoop.main)
|
||||
.sink { [weak self] (items) in
|
||||
.sink { [weak self] items in
|
||||
guard let menu = self?.syntaxesMenu else { return }
|
||||
|
||||
let recolorItem = menu.items.first { $0.action == #selector((any SyntaxChanging).recolorAll) }
|
||||
@ -165,7 +165,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
// build Unicode normalization menu items
|
||||
self.normalizationMenu?.items = (UnicodeNormalizationForm.standardForms + [nil] +
|
||||
UnicodeNormalizationForm.modifiedForms)
|
||||
.map { (form) in
|
||||
.map { form in
|
||||
guard let form else { return .separator() }
|
||||
|
||||
let item = NSMenuItem()
|
||||
|
@ -112,7 +112,7 @@ final class AppearancePaneController: NSViewController, NSMenuItemValidation, NS
|
||||
ThemeManager.shared.didUpdateSetting
|
||||
.compactMap(\.new)
|
||||
.receive(on: RunLoop.main)
|
||||
.sink { [weak self] (name) in
|
||||
.sink { [weak self] name in
|
||||
guard
|
||||
name == self?.selectedThemeName,
|
||||
let latestTheme = ThemeManager.shared.setting(name: name)
|
||||
|
@ -84,13 +84,13 @@ struct CharacterCountOptionsView: View {
|
||||
Toggle("Normalization:", isOn: $setting.normalizes)
|
||||
Picker("Normalization:", selection: $setting.normalizationForm) {
|
||||
Section {
|
||||
ForEach(UnicodeNormalizationForm.standardForms, id: \.self) { (form) in
|
||||
ForEach(UnicodeNormalizationForm.standardForms, id: \.self) { form in
|
||||
Text(form.localizedName).tag(form)
|
||||
.help(form.localizedDescription)
|
||||
}
|
||||
}
|
||||
Section {
|
||||
ForEach(UnicodeNormalizationForm.modifiedForms, id: \.self) { (form) in
|
||||
ForEach(UnicodeNormalizationForm.modifiedForms, id: \.self) { form in
|
||||
Text(form.localizedName).tag(form)
|
||||
.help(form.localizedDescription)
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ final class DefinitionTableViewDelegate: NSObject, NSTableViewDelegate {
|
||||
row + 1 == tableView.numberOfRows, // the last row is selected
|
||||
let rowView = tableView.rowView(atRow: row, makeIfNecessary: true),
|
||||
let (column, textField) = (0 ..< rowView.numberOfColumns).lazy // find the leftmost text field column
|
||||
.compactMap({ (column) -> (Int, NSTextField)? in
|
||||
.compactMap({ column -> (Int, NSTextField)? in
|
||||
guard let textField = (rowView.view(atColumn: column) as? NSTableCellView)?.textField else { return nil }
|
||||
return (column, textField)
|
||||
}).first,
|
||||
|
@ -73,7 +73,7 @@ extension Document {
|
||||
get {
|
||||
let textStorage = NSTextStorage(string: self.textStorage.string)
|
||||
|
||||
textStorage.observeDirectEditing { [weak self] (editedString) in
|
||||
textStorage.observeDirectEditing { [weak self] editedString in
|
||||
self?.textView?.insert(string: editedString, at: .replaceAll)
|
||||
}
|
||||
|
||||
|
@ -120,8 +120,8 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingChanging
|
||||
|
||||
// observe syntax update
|
||||
self.syntaxUpdateObserver = SyntaxManager.shared.didUpdateSetting
|
||||
.filter { [weak self] (change) in change.old == self?.syntaxParser.syntax.name }
|
||||
.sink { [weak self] (change) in self?.setSyntax(name: change.new ?? BundledSyntaxName.none) }
|
||||
.filter { [weak self] change in change.old == self?.syntaxParser.syntax.name }
|
||||
.sink { [weak self] change in self?.setSyntax(name: change.new ?? BundledSyntaxName.none) }
|
||||
}
|
||||
|
||||
|
||||
@ -439,7 +439,7 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingChanging
|
||||
// 2. Open the save panel once and cancel it.
|
||||
// 3. Quit the application.
|
||||
// 4. Then, the application hangs up.
|
||||
super.save(to: url, ofType: typeName, for: saveOperation) { (error) in
|
||||
super.save(to: url, ofType: typeName, for: saveOperation) { error in
|
||||
defer {
|
||||
completionHandler(error)
|
||||
}
|
||||
@ -986,8 +986,8 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingChanging
|
||||
}
|
||||
|
||||
// change encoding interactively
|
||||
self.performActivity(withSynchronousWaiting: true) { [unowned self] (activityCompletionHandler) in
|
||||
let completionHandler = { [weak self] (didChange: Bool) in
|
||||
self.performActivity(withSynchronousWaiting: true) { [unowned self] activityCompletionHandler in
|
||||
let completionHandler = { [weak self] didChange in
|
||||
if !didChange, let self {
|
||||
// reset status bar selection for in case when the operation was invoked from the popup button in the status bar
|
||||
self.fileEncoding = self.fileEncoding
|
||||
|
@ -138,7 +138,7 @@ final class DocumentInspectorViewController: NSViewController {
|
||||
|
||||
document.$fileAttributes
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] (attributes) in
|
||||
.sink { [weak self] attributes in
|
||||
guard let info = self?.fileInfo else { return }
|
||||
|
||||
let dateFormat = Date.FormatStyle(date: .abbreviated, time: .shortened)
|
||||
@ -162,7 +162,7 @@ final class DocumentInspectorViewController: NSViewController {
|
||||
|
||||
document.analyzer.$result
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [info = self.editorInfo] (result) in
|
||||
.sink { [info = self.editorInfo] result in
|
||||
info.chars = result.characters.formatted
|
||||
info.lines = result.lines.formatted
|
||||
info.words = result.words.formatted
|
||||
|
@ -129,7 +129,7 @@ final class DocumentViewController: NSSplitViewController, ThemeChanging, NSTool
|
||||
|
||||
// observe appearance change for theme toggle
|
||||
self.appearanceObserver = self.view.publisher(for: \.effectiveAppearance)
|
||||
.sink { [weak self] (appearance) in
|
||||
.sink { [weak self] appearance in
|
||||
guard
|
||||
let self,
|
||||
!UserDefaults.standard[.pinsThemeAppearance],
|
||||
@ -653,7 +653,7 @@ final class DocumentViewController: NSSplitViewController, ThemeChanging, NSTool
|
||||
/// Change the tab width to desired number through a sheet.
|
||||
@IBAction func customizeTabWidth(_ sender: Any?) {
|
||||
|
||||
let view = CustomTabWidthView(tabWidth: self.tabWidth) { [weak self] (tabWidth) in
|
||||
let view = CustomTabWidthView(tabWidth: self.tabWidth) { [weak self] tabWidth in
|
||||
self?.tabWidth = tabWidth
|
||||
}
|
||||
let viewController = NSHostingController(rootView: view)
|
||||
@ -862,7 +862,7 @@ final class DocumentViewController: NSSplitViewController, ThemeChanging, NSTool
|
||||
self.outlineObserver = document.syntaxParser.$outlineItems
|
||||
.removeDuplicates()
|
||||
.receive(on: RunLoop.main)
|
||||
.sink { [weak self] (outlineItems) in
|
||||
.sink { [weak self] outlineItems in
|
||||
self?.editorViewControllers.forEach { $0.outlineItems = outlineItems }
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ final class DocumentWindowController: NSWindowController, NSWindowDelegate {
|
||||
|
||||
// observe appearance setting change
|
||||
self.appearanceModeObserver = UserDefaults.standard.publisher(for: .documentAppearance, initial: true)
|
||||
.map { (value) in
|
||||
.map { value in
|
||||
switch value {
|
||||
case .default: nil
|
||||
case .light: NSAppearance(named: .aqua)
|
||||
@ -529,7 +529,7 @@ extension DocumentWindowController: NSToolbarDelegate {
|
||||
item.action = #selector(DocumentViewController.toggleAutoTabExpand)
|
||||
item.menu.items = [
|
||||
.sectionHeader(title: String(localized: "Tab Width"))
|
||||
] + [2, 4, 8].map { (width) in
|
||||
] + [2, 4, 8].map { width in
|
||||
let item = NSMenuItem(title: width.formatted(), action: #selector(DocumentViewController.changeTabWidth), keyEquivalent: "")
|
||||
item.tag = width
|
||||
return item
|
||||
|
@ -133,7 +133,7 @@ final class DraggableHostingView<Content>: NSHostingView<Content> where Content:
|
||||
/// The area the receiver located in the superview.
|
||||
@MainActor private var preferredEdge: Edge? {
|
||||
|
||||
self.superview.flatMap { (superview) in
|
||||
self.superview.flatMap { superview in
|
||||
Edge(horizontal: superview.frame.width/2 < self.frame.midX ? .right : .left,
|
||||
vertical: superview.frame.height/2 < self.frame.midY ? .top : .bottom)
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ extension EditorTextView {
|
||||
/// show custom surround sheet
|
||||
@IBAction func surroundSelection(_ sender: Any?) {
|
||||
|
||||
let view = CustomSurroundStringView(pair: self.customSurroundPair) { [weak self] (pair) in
|
||||
let view = CustomSurroundStringView(pair: self.customSurroundPair) { [weak self] pair in
|
||||
self?.surroundSelections(begin: pair.begin, end: pair.end)
|
||||
self?.customSurroundPair = pair
|
||||
}
|
||||
|
@ -829,7 +829,7 @@ class EditorTextView: NSTextView, Themable, CurrentLineHighlighting, MultiCursor
|
||||
|
||||
// remove official selectedRanges from the sub insertion points
|
||||
let selectedRanges = self.selectedRanges.map(\.rangeValue)
|
||||
self.insertionLocations.removeAll { (location) in selectedRanges.contains { $0.touches(location) } }
|
||||
self.insertionLocations.removeAll { location in selectedRanges.contains { $0.touches(location) } }
|
||||
|
||||
if !stillSelectingFlag, !self.hasMultipleInsertions {
|
||||
self.selectionOrigins = [self.selectedRange.location]
|
||||
@ -1344,7 +1344,7 @@ class EditorTextView: NSTextView, Themable, CurrentLineHighlighting, MultiCursor
|
||||
// substring all selected attributed strings
|
||||
let selections: [NSAttributedString] = self.selectedRanges
|
||||
.map(\.rangeValue)
|
||||
.map { (selectedRange) in
|
||||
.map { selectedRange in
|
||||
let plainText = (self.string as NSString).substring(with: selectedRange)
|
||||
let styledText = NSMutableAttributedString(string: plainText, attributes: self.typingAttributes)
|
||||
|
||||
|
@ -93,7 +93,7 @@ final class EditorTextViewController: NSViewController, NSServicesMenuRequestor,
|
||||
|
||||
// observe text orientation for line number view
|
||||
self.orientationObserver = self.textView!.publisher(for: \.layoutOrientation, options: .initial)
|
||||
.sink { [weak self] (orientation) in
|
||||
.sink { [weak self] orientation in
|
||||
guard let self else { return assertionFailure() }
|
||||
|
||||
self.stackView?.orientation = switch orientation {
|
||||
@ -109,7 +109,7 @@ final class EditorTextViewController: NSViewController, NSServicesMenuRequestor,
|
||||
self.writingDirectionObserver = self.textView!.publisher(for: \.baseWritingDirection)
|
||||
.removeDuplicates()
|
||||
.map { $0 == .rightToLeft }
|
||||
.sink { [weak self] (isRTL) in
|
||||
.sink { [weak self] isRTL in
|
||||
guard
|
||||
let stackView = self?.stackView,
|
||||
let lineNumberView = self?.lineNumberView
|
||||
@ -254,7 +254,7 @@ final class EditorTextViewController: NSViewController, NSServicesMenuRequestor,
|
||||
let lineCount = (string as NSString).substring(with: textView.selectedRange).numberOfLines
|
||||
let lineRange = FuzzyRange(location: lineNumber, length: lineCount)
|
||||
|
||||
let view = GoToLineView(lineRange: lineRange) { (lineRange) in
|
||||
let view = GoToLineView(lineRange: lineRange) { lineRange in
|
||||
guard let range = textView.string.rangeForLine(in: lineRange) else { return false }
|
||||
|
||||
textView.select(range: range)
|
||||
@ -273,7 +273,7 @@ final class EditorTextViewController: NSViewController, NSServicesMenuRequestor,
|
||||
|
||||
guard let textView = self.textView else { return assertionFailure() }
|
||||
|
||||
let view = UnicodeInputView { [unowned textView] (character) in
|
||||
let view = UnicodeInputView { [unowned textView] character in
|
||||
// flag to skip line ending sanitization
|
||||
textView.isApprovedTextChange = true
|
||||
defer { textView.isApprovedTextChange = false }
|
||||
|
@ -188,7 +188,7 @@ extension FileDropItem {
|
||||
// -> Use NSImageRep because NSImage's `size` returns a DPI applied size.
|
||||
if self.format.contains(Variable.imageWidth.token) || self.format.contains(Variable.imageHeight.token) {
|
||||
var imageRep: NSImageRep?
|
||||
NSFileCoordinator().coordinate(readingItemAt: droppedFileURL, options: [.withoutChanges, .resolvesSymbolicLink], error: nil) { (newURL: URL) in
|
||||
NSFileCoordinator().coordinate(readingItemAt: droppedFileURL, options: [.withoutChanges, .resolvesSymbolicLink], error: nil) { newURL in
|
||||
imageRep = NSImageRep(contentsOf: newURL)
|
||||
}
|
||||
if let imageRep {
|
||||
|
@ -102,7 +102,7 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {
|
||||
// adjust clear button position according to the visibility of scroller area
|
||||
let scroller = self.findTextView?.enclosingScrollView?.verticalScroller
|
||||
self.scrollerStyleObserver = scroller?.publisher(for: \.scrollerStyle, options: .initial)
|
||||
.sink { [weak self, weak scroller] (scrollerStyle) in
|
||||
.sink { [weak self, weak scroller] scrollerStyle in
|
||||
var inset = 5.0
|
||||
if scrollerStyle == .legacy, let scroller {
|
||||
inset += scroller.thickness
|
||||
@ -121,12 +121,12 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {
|
||||
|
||||
// sync text view states with user default
|
||||
UserDefaults.standard.publisher(for: .findUsesRegularExpression, initial: true)
|
||||
.sink { [unowned self] (value) in
|
||||
.sink { [unowned self] value in
|
||||
self.findTextView?.isRegularExpressionMode = value
|
||||
self.replacementTextView?.isRegularExpressionMode = value
|
||||
},
|
||||
UserDefaults.standard.publisher(for: .findRegexUnescapesReplacementString, initial: true)
|
||||
.sink { [unowned self] (value) in
|
||||
.sink { [unowned self] value in
|
||||
self.replacementTextView?.parseMode = .replacement(unescapes: value)
|
||||
}
|
||||
]
|
||||
|
@ -607,7 +607,7 @@ final class FormatPaneController: NSViewController, NSMenuItemValidation, NSTabl
|
||||
/// - Parameter state: The setting state to edit, or `nil` for a new setting.
|
||||
private func presentSyntaxEditor(state: SettingState? = nil) {
|
||||
|
||||
let viewController = NSStoryboard(name: "SyntaxEditView").instantiateInitialController { (coder) in
|
||||
let viewController = NSStoryboard(name: "SyntaxEditView").instantiateInitialController { coder in
|
||||
SyntaxEditViewController(coder: coder, state: state)
|
||||
}!
|
||||
|
||||
|
@ -182,7 +182,7 @@ final class IncompatibleCharactersViewController: NSViewController {
|
||||
fixedConstraint.isActive = true
|
||||
|
||||
scrollView.isHidden = isCollapsed
|
||||
NSAnimationContext.runAnimationGroup { (context) in
|
||||
NSAnimationContext.runAnimationGroup { context in
|
||||
if !animate {
|
||||
context.duration = 0
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public extension NSBezierPath {
|
||||
|
||||
self.init()
|
||||
|
||||
cgPath.applyWithBlock { (pointer) in
|
||||
cgPath.applyWithBlock { pointer in
|
||||
let element = pointer.pointee
|
||||
|
||||
switch element.type {
|
||||
|
@ -51,7 +51,7 @@ extension NSDocument {
|
||||
final func presentErrorAsSheetSafely(_ error: some Error, synchronousWaiting waitSynchronously: Bool = false, recoveryHandler: RecoveryHandler? = nil) {
|
||||
|
||||
self.performActivity(withSynchronousWaiting: waitSynchronously) { [unowned self] activityCompletionHandler in
|
||||
self.presentErrorAsSheet(error) { (didRecover) in
|
||||
self.presentErrorAsSheet(error) { didRecover in
|
||||
activityCompletionHandler()
|
||||
recoveryHandler?(didRecover)
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ extension NSImage {
|
||||
|
||||
assert(self.isTemplate, "An image to tint should be a template image.")
|
||||
|
||||
let image = Self(size: self.size, flipped: false) { [image = self.copy() as! Self] (dstRect) -> Bool in
|
||||
let image = Self(size: self.size, flipped: false) { [image = self.copy() as! Self] dstRect -> Bool in
|
||||
|
||||
image.draw(in: dstRect)
|
||||
|
||||
|
@ -471,7 +471,7 @@ extension NSTextView {
|
||||
let scale = self.scale
|
||||
return layoutManager.insertionPointRects(at: index)
|
||||
.map { $0.offset(by: self.textContainerOrigin) }
|
||||
.map { (rect) in
|
||||
.map { rect in
|
||||
NSRect(x: (rect.minX * scale).rounded(.down) / scale,
|
||||
y: rect.minY,
|
||||
width: 1 / scale,
|
||||
|
@ -213,7 +213,7 @@ final class NavigationBarController: NSViewController {
|
||||
guard let outlineMenu = self.outlineMenu?.menu else { return assertionFailure() }
|
||||
|
||||
outlineMenu.items = outlineItems
|
||||
.flatMap { (outlineItem) -> [NSMenuItem] in
|
||||
.flatMap { outlineItem in
|
||||
switch outlineItem.title {
|
||||
case .separator:
|
||||
// dummy item to avoid merging sequential separators into a single separator
|
||||
|
@ -127,7 +127,7 @@ extension BidirectionalCollection<OutlineItem> {
|
||||
/// - Returns: Matched items.
|
||||
func filterItems(with searchString: String) -> [OutlineItem] {
|
||||
|
||||
self.compactMap { (item) in
|
||||
self.compactMap { item in
|
||||
item.title.abbreviatedMatch(with: searchString).flatMap { (item: item, result: $0) }
|
||||
}
|
||||
.map {
|
||||
|
@ -62,7 +62,7 @@ final class ScriptManager: NSObject, NSFilePresenter {
|
||||
|
||||
self.syntaxObserver = (DocumentController.shared as! DocumentController).$currentSyntaxName
|
||||
.removeDuplicates()
|
||||
.sink { [unowned self] (styleName) in Task { @MainActor in self.currentContext = styleName } }
|
||||
.sink { [unowned self] styleName in Task { @MainActor in self.currentContext = styleName } }
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ final class ShortcutField: NSTextField, NSTextViewDelegate {
|
||||
fieldEditor.delegate = self
|
||||
}
|
||||
|
||||
self.keyDownMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [unowned self] (event) -> NSEvent? in
|
||||
self.keyDownMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [unowned self] event -> NSEvent? in
|
||||
guard let shortcut = Shortcut(keyDownEvent: event) else { return event }
|
||||
|
||||
if event.keyCode == 53, shortcut.modifierMask.isEmpty { // single Escape
|
||||
|
@ -32,7 +32,7 @@ struct WidthGetter<Key: PreferenceKey>: View where Key.Value == CGFloat {
|
||||
|
||||
var body: some View {
|
||||
|
||||
GeometryReader { (geometry) in
|
||||
GeometryReader { geometry in
|
||||
Color.clear.preference(key: self.key.self, value: geometry.size.width)
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ extension Snippet {
|
||||
func insertions(for string: String, ranges: [NSRange]) -> (strings: [String], selectedRanges: [NSRange]?) {
|
||||
|
||||
var offset = 0
|
||||
let insertions = ranges.map { (range) in
|
||||
let insertions = ranges.map { range in
|
||||
let selectedString = (string as NSString).substring(with: range)
|
||||
let indent = string.rangeOfIndent(at: range.location)
|
||||
.flatMap { (string as NSString).substring(with: $0) } ?? ""
|
||||
|
@ -49,7 +49,7 @@ final class TextContainer: NSTextContainer {
|
||||
|
||||
didSet {
|
||||
self.typingAttributesObserver = textView?.publisher(for: \.typingAttributes, options: .initial)
|
||||
.sink { [weak self] (typingAttributes) in
|
||||
.sink { [weak self] typingAttributes in
|
||||
// -> The font can differ from the specified text font while typing marked text.
|
||||
guard self?.textView?.hasMarkedText() != true else { return }
|
||||
|
||||
|
@ -118,7 +118,7 @@ final class TextSelection: NSObject {
|
||||
let string = textView.selectedString
|
||||
let textStorage = NSTextStorage(string: string)
|
||||
|
||||
textStorage.observeDirectEditing { (editedString) in
|
||||
textStorage.observeDirectEditing { editedString in
|
||||
textView.insert(string: editedString, at: .replaceSelection)
|
||||
}
|
||||
|
||||
|
@ -186,15 +186,15 @@ extension TokenRepresentable {
|
||||
|
||||
private extension NSColor {
|
||||
|
||||
static let tokenTextColor = NSColor(name: nil) { (appearance) in
|
||||
static let tokenTextColor = NSColor(name: nil) { appearance in
|
||||
NSColor.selectedControlColor.blended(withFraction: 0.7, of: appearance.isDark ? .white : .black)!
|
||||
}
|
||||
|
||||
static let tokenBracketColor = NSColor(name: nil) { (appearance) in
|
||||
static let tokenBracketColor = NSColor(name: nil) { appearance in
|
||||
NSColor.selectedControlColor.blended(withFraction: 0.3, of: appearance.isDark ? .white : .black)!
|
||||
}
|
||||
|
||||
static let tokenBackgroundColor = NSColor(name: nil) { (appearance) in
|
||||
static let tokenBackgroundColor = NSColor(name: nil) { appearance in
|
||||
NSColor.selectedControlColor.withAlphaComponent(appearance.isDark ? 0.5 : 0.3)
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ extension NSTextStorage {
|
||||
let links: [ValueRange<URL>] = try await Task.detached {
|
||||
try NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
|
||||
.cancellableMatches(in: string, range: range)
|
||||
.compactMap { (result) in
|
||||
.compactMap { result in
|
||||
guard let url = result.url else { return nil }
|
||||
return ValueRange(value: url, range: result.range)
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ final actor UserUnixTask {
|
||||
|
||||
let data = Data(input.utf8)
|
||||
|
||||
self.inputPipe.fileHandleForWriting.writeabilityHandler = { (handle) in
|
||||
self.inputPipe.fileHandleForWriting.writeabilityHandler = { handle in
|
||||
do {
|
||||
try handle.write(contentsOf: data)
|
||||
try handle.close()
|
||||
@ -120,8 +120,8 @@ private extension Pipe {
|
||||
/// Create asynchronous stream for the standard output.
|
||||
var readingStream: AsyncStream<Data> {
|
||||
|
||||
AsyncStream { (continuation) in
|
||||
self.fileHandleForReading.readabilityHandler = { (handle) in
|
||||
AsyncStream { continuation in
|
||||
self.fileHandleForReading.readabilityHandler = { handle in
|
||||
let data = handle.availableData
|
||||
if data.isEmpty {
|
||||
handle.readabilityHandler = nil
|
||||
|
@ -38,7 +38,7 @@ final class LineEndingScannerTests: XCTestCase {
|
||||
// test async line ending scan
|
||||
let expectation = self.expectation(description: "didScanLineEndings")
|
||||
let observer = scanner.$inconsistentLineEndings
|
||||
.sink { (lineEndings) in
|
||||
.sink { lineEndings in
|
||||
XCTAssertEqual(lineEndings, [ValueRange(value: .nel, range: NSRange(location: 3, length: 1)),
|
||||
ValueRange(value: .crlf, range: NSRange(location: 11, length: 2))])
|
||||
expectation.fulfill()
|
||||
@ -62,7 +62,7 @@ final class LineEndingScannerTests: XCTestCase {
|
||||
// test async line ending scan
|
||||
let expectation = self.expectation(description: "didScanLineEndings")
|
||||
let observer = scanner.$inconsistentLineEndings
|
||||
.sink { (lineEndings) in
|
||||
.sink { lineEndings in
|
||||
XCTAssert(lineEndings.isEmpty)
|
||||
expectation.fulfill()
|
||||
}
|
||||
@ -85,7 +85,7 @@ final class LineEndingScannerTests: XCTestCase {
|
||||
// test async line ending scan
|
||||
let expectation = self.expectation(description: "didScanLineEndings")
|
||||
let observer = scanner.$inconsistentLineEndings
|
||||
.sink { (lineEndings) in
|
||||
.sink { lineEndings in
|
||||
XCTAssertEqual(lineEndings, [ValueRange(value: .crlf, range: NSRange(location: 3, length: 2)),
|
||||
ValueRange(value: .cr, range: NSRange(location: 8, length: 1))])
|
||||
expectation.fulfill()
|
||||
|
@ -126,7 +126,7 @@ final class SyntaxTests: XCTestCase {
|
||||
self.outlineParseCancellable = parser.$outlineItems
|
||||
.compactMap { $0 } // ignore the initial invocation
|
||||
.receive(on: RunLoop.main)
|
||||
.sink { (outlineItems) in
|
||||
.sink { outlineItems in
|
||||
outlineParseExpectation.fulfill()
|
||||
|
||||
XCTAssertEqual(outlineItems.count, 3)
|
||||
|
@ -9,7 +9,7 @@
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// © 2019-2021 1024jp
|
||||
// © 2019-2023 1024jp
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -40,7 +40,7 @@ final class UserDefaultsObservationTests: XCTestCase {
|
||||
UserDefaults.standard[key] = false
|
||||
|
||||
let observer = UserDefaults.standard.publisher(for: key)
|
||||
.sink { (value) in
|
||||
.sink { value in
|
||||
XCTAssertTrue(value)
|
||||
XCTAssertEqual(OperationQueue.current, .main)
|
||||
|
||||
@ -66,7 +66,7 @@ final class UserDefaultsObservationTests: XCTestCase {
|
||||
UserDefaults.standard[key] = false
|
||||
|
||||
let observer = UserDefaults.standard.publisher(for: key, initial: true)
|
||||
.sink { (value) in
|
||||
.sink { value in
|
||||
XCTAssertFalse(value)
|
||||
expectation.fulfill()
|
||||
}
|
||||
@ -90,7 +90,7 @@ final class UserDefaultsObservationTests: XCTestCase {
|
||||
|
||||
let expectation = self.expectation(description: "UserDefaults observation for optional key")
|
||||
let observer = UserDefaults.standard.publisher(for: key)
|
||||
.sink { (value) in
|
||||
.sink { value in
|
||||
XCTAssertNil(value)
|
||||
expectation.fulfill()
|
||||
}
|
||||
@ -118,7 +118,7 @@ final class UserDefaultsObservationTests: XCTestCase {
|
||||
UserDefaults.standard[key] = .dog
|
||||
|
||||
let observer = UserDefaults.standard.publisher(for: key)
|
||||
.sink { (value) in
|
||||
.sink { value in
|
||||
XCTAssertEqual(value, .cow)
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user