diff --git a/NvimView/DrawerDev/Info.plist b/NvimView/DrawerDev/Info.plist index e03cc10a..68f70e71 100644 --- a/NvimView/DrawerDev/Info.plist +++ b/NvimView/DrawerDev/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.30.0 + SNAPSHOT-336 CFBundleVersion - 335 + 336 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright diff --git a/NvimView/DrawerPerf/Info.plist b/NvimView/DrawerPerf/Info.plist index 20547c33..91e7dc62 100644 --- a/NvimView/DrawerPerf/Info.plist +++ b/NvimView/DrawerPerf/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.30.0 + SNAPSHOT-336 CFBundleVersion - 335 + 336 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright diff --git a/NvimView/MinimalNvimViewDemo/Info.plist b/NvimView/MinimalNvimViewDemo/Info.plist index e5fbf03b..59351b11 100644 --- a/NvimView/MinimalNvimViewDemo/Info.plist +++ b/NvimView/MinimalNvimViewDemo/Info.plist @@ -38,9 +38,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.30.0 + SNAPSHOT-336 CFBundleVersion - 335 + 336 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright diff --git a/NvimView/NvimView.xcodeproj/project.pbxproj b/NvimView/NvimView.xcodeproj/project.pbxproj index 2d2fcf8b..d42511a7 100644 --- a/NvimView/NvimView.xcodeproj/project.pbxproj +++ b/NvimView/NvimView.xcodeproj/project.pbxproj @@ -1146,7 +1146,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 335; + CURRENT_PROJECT_VERSION = 336; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -1208,7 +1208,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 335; + CURRENT_PROJECT_VERSION = 336; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -1238,7 +1238,7 @@ COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 335; + DYLIB_CURRENT_VERSION = 336; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac"; FRAMEWORK_VERSION = A; @@ -1260,7 +1260,7 @@ COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 335; + DYLIB_CURRENT_VERSION = 336; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac"; FRAMEWORK_VERSION = A; diff --git a/NvimView/NvimView/Info.plist b/NvimView/NvimView/Info.plist index f2e01b31..71abf65c 100644 --- a/NvimView/NvimView/Info.plist +++ b/NvimView/NvimView/Info.plist @@ -15,9 +15,9 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.30.0 + SNAPSHOT-336 CFBundleVersion - 335 + 336 NSHumanReadableCopyright Copyright © 2017 Tae Won Ha. All rights reserved. NSPrincipalClass diff --git a/NvimView/NvimView/NvimApiCommons.swift b/NvimView/NvimView/NvimApiCommons.swift index 5c6bfe2f..4d6239b2 100644 --- a/NvimView/NvimView/NvimApiCommons.swift +++ b/NvimView/NvimView/NvimApiCommons.swift @@ -9,7 +9,7 @@ import RxSwift extension RxNeovimApi { public func getDirtyStatus( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -23,7 +23,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_dirty_status", params: params, expectsReturnValue: true) @@ -38,7 +38,7 @@ extension RxNeovimApi { public func bufGetInfo( buffer: RxNeovimApi.Buffer, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -53,7 +53,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_info", params: params) diff --git a/NvimView/NvimView/NvimView+Key.swift b/NvimView/NvimView/NvimView+Key.swift index feae67d5..82f7aaca 100644 --- a/NvimView/NvimView/NvimView+Key.swift +++ b/NvimView/NvimView/NvimView+Key.swift @@ -41,7 +41,7 @@ extension NvimView { let finalInput = isWrapNeeded ? self.wrapNamedKeys(flags + namedChars) : self.vimPlainString(chars) - _ = self.api.input(keys: finalInput, checkBlocked: false).syncValue() + _ = self.api.input(keys: finalInput, errWhenBlocked: false).syncValue() self.keyDownDone = true } @@ -130,7 +130,7 @@ extension NvimView { // So we escape as early as possible if chars == "\0" { self.api - .input(keys: self.wrapNamedKeys("Nul"), checkBlocked: false) + .input(keys: self.wrapNamedKeys("Nul"), errWhenBlocked: false) .subscribe() .disposed(by: self.disposeBag) return true @@ -141,7 +141,7 @@ extension NvimView { // Also mentioned in MacVim's KeyBindings.plist if .control == flags && chars == "6" { self.api - .input(keys: "\u{1e}", checkBlocked: false) // AKA ^^ + .input(keys: "\u{1e}", errWhenBlocked: false) // AKA ^^ .subscribe() .disposed(by: self.disposeBag) return true @@ -150,7 +150,7 @@ extension NvimView { if .control == flags && chars == "2" { // should generate \0, escaping as above self.api - .input(keys: self.wrapNamedKeys("Nul"), checkBlocked: false) + .input(keys: self.wrapNamedKeys("Nul"), errWhenBlocked: false) .subscribe() .disposed(by: self.disposeBag) return true diff --git a/NvimView/NvimView/NvimView+MenuItems.swift b/NvimView/NvimView/NvimView+MenuItems.swift index 4597dda2..230a3c82 100644 --- a/NvimView/NvimView/NvimView+MenuItems.swift +++ b/NvimView/NvimView/NvimView+MenuItems.swift @@ -50,14 +50,14 @@ extension NvimView { switch self.mode { case .insert, .replace: self.api - .input(keys: "ui", checkBlocked: false) + .input(keys: "ui", errWhenBlocked: false) .subscribe(onError: { error in self.eventsSubject.onNext(.apiError(msg: "Could not undo", cause: error)) }) .disposed(by: self.disposeBag) case .normal, .visual: self.api - .input(keys: "u", checkBlocked: false) + .input(keys: "u", errWhenBlocked: false) .subscribe(onError: { error in self.eventsSubject.onNext(.apiError(msg: "Could not undo", cause: error)) }) @@ -71,14 +71,14 @@ extension NvimView { switch self.mode { case .insert, .replace: self.api - .input(keys: "i", checkBlocked: false) + .input(keys: "i", errWhenBlocked: false) .subscribe(onError: { error in self.eventsSubject.onNext(.apiError(msg: "Could not redo", cause: error)) }) .disposed(by: self.disposeBag) case .normal, .visual: self.api - .input(keys: "", checkBlocked: false) + .input(keys: "", errWhenBlocked: false) .subscribe(onError: { error in self.eventsSubject.onNext(.apiError(msg: "Could not redo", cause: error)) }) @@ -92,7 +92,7 @@ extension NvimView { switch self.mode { case .visual, .normal: self.api - .input(keys: "\"+d", checkBlocked: false) + .input(keys: "\"+d", errWhenBlocked: false) .subscribe(onError: { error in self.eventsSubject.onNext(.apiError(msg: "Could not cut", cause: error)) }) @@ -106,7 +106,7 @@ extension NvimView { switch self.mode { case .visual, .normal: self.api - .input(keys: "\"+y", checkBlocked: false) + .input(keys: "\"+y", errWhenBlocked: false) .subscribe(onError: { error in self.eventsSubject.onNext(.apiError(msg: "Could not copy", cause: error)) }) @@ -125,7 +125,7 @@ extension NvimView { || self.mode == .replace || self.mode == .termFocus { self.api - .input(keys: self.vimPlainString(content), checkBlocked: false) + .input(keys: self.vimPlainString(content), errWhenBlocked: false) .subscribe(onError: { error in self.eventsSubject.onNext(.apiError(msg: "Could not paste \(content)", cause: error)) }) @@ -156,12 +156,12 @@ extension NvimView { case .insert: let cmd = element.column == 0 ? "\"+Pa" : "\"+pa" return self.api - .input(keys: cmd, checkBlocked: false).asCompletable() + .input(keys: cmd, errWhenBlocked: false).asCompletable() .andThen(Single.just(element.pasteModeSet)) case .normal, .visual: return self.api - .input(keys: "\"+p", checkBlocked: false).asCompletable() + .input(keys: "\"+p", errWhenBlocked: false).asCompletable() .andThen(Single.just(element.pasteModeSet)) default: @@ -186,7 +186,7 @@ extension NvimView { switch self.mode { case .normal, .visual: self.api - .input(keys: "x", checkBlocked: false) + .input(keys: "x", errWhenBlocked: false) .subscribe(onError: { error in self.eventsSubject.onNext(.apiError(msg: "Could not delete", cause: error)) }) @@ -200,14 +200,14 @@ extension NvimView { switch self.mode { case .insert, .visual: self.api - .input(keys: "ggVG", checkBlocked: false) + .input(keys: "ggVG", errWhenBlocked: false) .subscribe(onError: { error in self.eventsSubject.onNext(.apiError(msg: "Could not select all", cause: error)) }) .disposed(by: self.disposeBag) default: self.api - .input(keys: "ggVG", checkBlocked: false) + .input(keys: "ggVG", errWhenBlocked: false) .subscribe(onError: { error in self.eventsSubject.onNext(.apiError(msg: "Could not select all", cause: error)) }) diff --git a/NvimView/NvimView/NvimView+Mouse.swift b/NvimView/NvimView/NvimView+Mouse.swift index 47a35d69..82aee2c1 100644 --- a/NvimView/NvimView/NvimView+Mouse.swift +++ b/NvimView/NvimView/NvimView+Mouse.swift @@ -34,9 +34,9 @@ extension NvimView { modifierFlags: event.modifierFlags, cellPosition: cellPosition) self.api - .input(keys: vimInputX, checkBlocked: false).asCompletable() + .input(keys: vimInputX, errWhenBlocked: false).asCompletable() .andThen( - self.api.input(keys: vimInputY, checkBlocked: false).asCompletable() + self.api.input(keys: vimInputY, errWhenBlocked: false).asCompletable() ) .subscribe() .disposed(by: self.disposeBag) @@ -120,7 +120,7 @@ extension NvimView { } self.api - .input(keys: result, checkBlocked: false) + .input(keys: result, errWhenBlocked: false) .subscribe() .disposed(by: self.disposeBag) } diff --git a/NvimView/NvimView/NvimView.swift b/NvimView/NvimView/NvimView.swift index 6f5023b1..5b746446 100644 --- a/NvimView/NvimView/NvimView.swift +++ b/NvimView/NvimView/NvimView.swift @@ -65,17 +65,17 @@ public class NvimView: NSView, self.updateFontMetaData(self._font) } } - + public var characterspacing: CGFloat { get { return self._characterspacing } - + set { guard newValue >= 0.0 else { return } - + self._characterspacing = newValue self.updateFontMetaData(self._font) } @@ -121,10 +121,6 @@ public class NvimView: NSView, return true } - public let queue = DispatchQueue( - label: String(reflecting: NvimView.self), - qos: .userInteractive - ) public let scheduler: SerialDispatchQueueScheduler public internal(set) var currentPosition = Position.beginning @@ -140,9 +136,11 @@ public class NvimView: NSView, characterspacing: self._characterspacing, usesLigatures: self.usesLigatures ) - self.bridge = UiBridge(uuid: self.uuid, queue: self.queue, config: config) - self.scheduler = SerialDispatchQueueScheduler(queue: self.queue, - internalSerialQueueName: "com.qvacua.NvimView.NvimView") + self.bridge = UiBridge(uuid: self.uuid, config: config) + self.scheduler = SerialDispatchQueueScheduler( + queue: self.queue, + internalSerialQueueName: "com.qvacua.NvimView.NvimView" + ) self.sourceFileUrls = config.sourceFiles @@ -154,8 +152,6 @@ public class NvimView: NSView, self.cellSize = FontUtils.cellSize( of: self.font, linespacing: self.linespacing, characterspacing: self.characterspacing ) - - self.api.queue = self.queue } convenience override public init(frame rect: NSRect) { @@ -182,6 +178,11 @@ public class NvimView: NSView, } // MARK: - Internal + let queue = DispatchQueue( + label: String(reflecting: NvimView.self), + qos: .userInteractive + ) + let bridge: UiBridge let api = RxNeovimApi() diff --git a/NvimView/NvimView/UiBridge.swift b/NvimView/NvimView/UiBridge.swift index 15270cb6..c8ef0059 100644 --- a/NvimView/NvimView/UiBridge.swift +++ b/NvimView/NvimView/UiBridge.swift @@ -41,7 +41,7 @@ class UiBridge { weak var consumer: UiBridgeConsumer? - init(uuid: UUID, queue: DispatchQueue, config: NvimView.Config) { + init(uuid: UUID, config: NvimView.Config) { self.uuid = uuid self.useInteractiveZsh = config.useInteractiveZsh @@ -60,11 +60,10 @@ class UiBridge { self.log.debug("Using ENVs from login shell: \(self.envDict)") } - self.queue = queue - self.scheduler = SerialDispatchQueueScheduler(queue: queue, - internalSerialQueueName: String(reflecting: UiBridge.self)) - self.client.queue = self.queue - self.server.queue = self.queue + self.scheduler = SerialDispatchQueueScheduler( + queue: queue, + internalSerialQueueName: String(reflecting: UiBridge.self) + ) self.server.stream .subscribe(onNext: { [weak self] message in @@ -334,7 +333,10 @@ class UiBridge { private var runLocalServerAndNvimCompletable: Completable.CompletableObserver? private let scheduler: SerialDispatchQueueScheduler - private let queue: DispatchQueue + private let queue = DispatchQueue( + label: String(reflecting: UiBridge.self), + qos: .userInitiated + ) private let disposeBag = DisposeBag() diff --git a/NvimView/NvimViewTests/Info.plist b/NvimView/NvimViewTests/Info.plist index 28cc8501..4c625fba 100644 --- a/NvimView/NvimViewTests/Info.plist +++ b/NvimView/NvimViewTests/Info.plist @@ -15,8 +15,8 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 0.30.0 + SNAPSHOT-336 CFBundleVersion - 335 + 336 diff --git a/RxPack/RxMessagePort.swift b/RxPack/RxMessagePort.swift index 1b11c5eb..7992d6dd 100644 --- a/RxPack/RxMessagePort.swift +++ b/RxPack/RxMessagePort.swift @@ -17,25 +17,12 @@ public final class RxMessagePortClient { public static func responseCodeToString(code: Int32) -> String { switch code { - - case kCFMessagePortSendTimeout: - return "kCFMessagePortSendTimeout" - - case kCFMessagePortReceiveTimeout: - return "kCFMessagePortReceiveTimeout" - - case kCFMessagePortIsInvalid: - return "kCFMessagePortIsInvalid" - - case kCFMessagePortTransportError: - return "kCFMessagePortTransportError" - - case kCFMessagePortBecameInvalidError: - return "kCFMessagePortBecameInvalidError" - - default: - return "unknown" - + case kCFMessagePortSendTimeout:return "kCFMessagePortSendTimeout" + case kCFMessagePortReceiveTimeout:return "kCFMessagePortReceiveTimeout" + case kCFMessagePortIsInvalid:return "kCFMessagePortIsInvalid" + case kCFMessagePortTransportError:return "kCFMessagePortTransportError" + case kCFMessagePortBecameInvalidError:return "kCFMessagePortBecameInvalidError" + default:return "unknown" } } } @@ -44,60 +31,50 @@ public final class RxMessagePortClient { public var timeout = RxMessagePortClient.defaultTimeout - public var queue = DispatchQueue( - label: String(reflecting: RxMessagePortClient.self), - qos: .userInitiated - ) - - public init() { - } - public func send( msgid: Int32, data: Data?, expectsReply: Bool ) -> Single { - return Single.create { single in + Single.create { single in self.queue.async { - self.portLock.withReadLock { - guard self.portIsValid else { - single(.error(Error.portInvalid)) - return - } - - let returnDataPtr: UnsafeMutablePointer?> - = UnsafeMutablePointer.allocate(capacity: 1) - defer { returnDataPtr.deallocate() } - - let responseCode = CFMessagePortSendRequest( - self.port, - msgid, - data?.cfdata, - self.timeout, - self.timeout, - expectsReply ? CFRunLoopMode.defaultMode.rawValue : nil, - expectsReply ? returnDataPtr : nil - ) - - guard responseCode == kCFMessagePortSuccess else { - single(.error(Error.send(msgid: msgid, response: responseCode))) - return - } - - guard expectsReply else { - single(.success(nil)) - return - } - - // Upon return, [returnData] contains a CFData object - // containing the reply data. Ownership follows the The Create Rule. - // From: https://developer.apple.com/documentation/corefoundation/1543076-cfmessageportsendrequest - // This means that we have to release the returned CFData. - // Thus, we have to use Unmanaged.takeRetainedValue() - // See also https://www.mikeash.com/pyblog/friday-qa-2017-08-11-swiftunmanaged.html - let data: Data? = returnDataPtr.pointee?.takeRetainedValue().data - single(.success(data)) + guard self.portIsValid else { + single(.error(Error.portInvalid)) + return } + + let returnDataPtr: UnsafeMutablePointer?> + = UnsafeMutablePointer.allocate(capacity: 1) + defer { returnDataPtr.deallocate() } + + let responseCode = CFMessagePortSendRequest( + self.port, + msgid, + data?.cfdata, + self.timeout, + self.timeout, + expectsReply ? CFRunLoopMode.defaultMode.rawValue : nil, + expectsReply ? returnDataPtr : nil + ) + + guard responseCode == kCFMessagePortSuccess else { + single(.error(Error.send(msgid: msgid, response: responseCode))) + return + } + + guard expectsReply else { + single(.success(nil)) + return + } + + // Upon return, [returnData] contains a CFData object + // containing the reply data. Ownership follows the The Create Rule. + // From: https://developer.apple.com/documentation/corefoundation/1543076-cfmessageportsendrequest + // This means that we have to release the returned CFData. + // Thus, we have to use Unmanaged.takeRetainedValue() + // See also https://www.mikeash.com/pyblog/friday-qa-2017-08-11-swiftunmanaged.html + let data: Data? = returnDataPtr.pointee?.takeRetainedValue().data + single(.success(data)) } return Disposables.create() @@ -105,34 +82,30 @@ public final class RxMessagePortClient { } public func connect(to name: String) -> Completable { - return Completable.create { completable in + Completable.create { completable in self.queue.async { - self.portLock.withWriteLock { - self.port = CFMessagePortCreateRemote(kCFAllocatorDefault, name.cfstr) + self.port = CFMessagePortCreateRemote(kCFAllocatorDefault, name.cfstr) - if self.port == nil { - completable(.error(Error.clientInit)) - return - } - - self.portIsValid = true - completable(.completed) + if self.port == nil { + completable(.error(Error.clientInit)) + return } + + self.portIsValid = true + completable(.completed) } return Disposables.create() } } public func stop() -> Completable { - return Completable.create { completable in + Completable.create { completable in self.queue.async { - self.portLock.withWriteLock { - self.portIsValid = false - if self.port != nil && CFMessagePortIsValid(self.port) { - CFMessagePortInvalidate(self.port) - } - completable(.completed) + self.portIsValid = false + if self.port != nil && CFMessagePortIsValid(self.port) { + CFMessagePortInvalidate(self.port) } + completable(.completed) } return Disposables.create() @@ -140,8 +113,12 @@ public final class RxMessagePortClient { } private var portIsValid = false - private let portLock = ReadersWriterLock() private var port: CFMessagePort? + + private let queue = DispatchQueue( + label: String(reflecting: RxMessagePortClient.self), + qos: .userInitiated + ) } public final class RxMessagePortServer { @@ -155,29 +132,16 @@ public final class RxMessagePortServer { } public var syncReplyBody: SyncReplyBody? { - get { - return self.messageHandler.syncReplyBody - } - set { - self.messageHandler.syncReplyBody = newValue - } + get { self.messageHandler.syncReplyBody } + set { self.messageHandler.syncReplyBody = newValue } } - public var stream: Observable { - return self.streamSubject.asObservable() - } + public var stream: Observable { self.streamSubject.asObservable() } - public var queue = DispatchQueue( - label: String(reflecting: RxMessagePortServer.self), - qos: .userInitiated - ) - - public init() { - self.messageHandler = MessageHandler(subject: self.streamSubject) - } + public init() { self.messageHandler = MessageHandler(subject: self.streamSubject) } public func run(as name: String) -> Completable { - return Completable.create { completable in + Completable.create { completable in self.queue.async { var localCtx = CFMessagePortContext( version: 0, @@ -193,8 +157,7 @@ public final class RxMessagePortServer { { _, msgid, data, info in guard let infoPtr = UnsafeRawPointer(info) else { return nil } - let handler = Unmanaged - .fromOpaque(infoPtr).takeUnretainedValue() + let handler = Unmanaged.fromOpaque(infoPtr).takeUnretainedValue() return handler.handleMessage(msgId: msgid, cfdata: data) }, &localCtx, @@ -218,14 +181,12 @@ public final class RxMessagePortServer { } public func stop() -> Completable { - return Completable.create { completable in + Completable.create { completable in self.queue.async { self.messageHandler.syncReplyBody = nil self.streamSubject.onCompleted() - if let portRunLoop = self.portRunLoop { - CFRunLoopStop(portRunLoop) - } + if let portRunLoop = self.portRunLoop { CFRunLoopStop(portRunLoop) } if self.port != nil && CFMessagePortIsValid(self.port) { CFMessagePortInvalidate(self.port) @@ -242,16 +203,17 @@ public final class RxMessagePortServer { private var portThread: Thread? private var portRunLoop: CFRunLoop? + private let queue = DispatchQueue( + label: String(reflecting: RxMessagePortClient.self), + qos: .userInitiated + ) + private var messageHandler: MessageHandler private let streamSubject = PublishSubject() private func runServer() { self.portRunLoop = CFRunLoopGetCurrent() - let runLoopSrc = CFMessagePortCreateRunLoopSource( - kCFAllocatorDefault, - self.port, - 0 - ) + let runLoopSrc = CFMessagePortCreateRunLoopSource(kCFAllocatorDefault, self.port, 0) CFRunLoopAddSource(self.portRunLoop, runLoopSrc, .defaultMode) CFRunLoopRun() } @@ -261,9 +223,7 @@ private class MessageHandler { fileprivate var syncReplyBody: RxMessagePortServer.SyncReplyBody? - fileprivate init(subject: PublishSubject) { - self.subject = subject - } + fileprivate init(subject: PublishSubject) { self.subject = subject } fileprivate func handleMessage( msgId: Int32, @@ -286,21 +246,15 @@ private class MessageHandler { private extension Data { - var cfdata: CFData { - return self as NSData - } + var cfdata: CFData { self as NSData } } private extension CFData { - var data: Data { - return self as NSData as Data - } + var data: Data { self as NSData as Data } } private extension String { - var cfstr: CFString { - return self as NSString - } + var cfstr: CFString { self as NSString } } diff --git a/RxPack/RxMsgpackRpc.swift b/RxPack/RxMsgpackRpc.swift index bb7e47b4..eca729ee 100644 --- a/RxPack/RxMsgpackRpc.swift +++ b/RxPack/RxMsgpackRpc.swift @@ -48,9 +48,7 @@ public final class RxMsgpackRpc { Streams `Message.notification`s and `Message.error`s by default. When `streamResponses` is set to `true`, then also `Message.response`s. */ - public var stream: Observable { - return self.streamSubject.asObservable() - } + public var stream: Observable { self.streamSubject.asObservable() } /** When `true`, all messages of type `MessageType.response` are also streamed @@ -60,39 +58,26 @@ public final class RxMsgpackRpc { */ public var streamResponses = false - public var queue = DispatchQueue( - label: String(reflecting: RxMsgpackRpc.self), - qos: .userInitiated - ) - - private var socket: Socket? - private var thread: Thread? - - public init() { - } - public func run(at path: String) -> Completable { - return Completable.create { completable in + Completable.create { completable in self.queue.async { - self.stopLock.withWriteLock { - self.stopped = false + self.stopped = false - do { - try self.socket = Socket.create( - family: .unix, - type: .stream, - proto: .unix - ) - try self.socket?.connect(to: path) - self.setUpThreadAndStartReading() - } catch { - self.streamSubject.onError( - Error(msg: "Could not get socket", cause: error) - ) - completable(.error( - Error(msg: "Could not get socket at \(path)", cause: error) - )) - } + do { + try self.socket = Socket.create( + family: .unix, + type: .stream, + proto: .unix + ) + try self.socket?.connect(to: path) + self.setUpThreadAndStartReading() + } catch { + self.streamSubject.onError( + Error(msg: "Could not get socket", cause: error) + ) + completable(.error( + Error(msg: "Could not get socket at \(path)", cause: error) + )) } completable(.completed) @@ -103,14 +88,12 @@ public final class RxMsgpackRpc { } public func stop() -> Completable { - return Completable.create { completable in + Completable.create { completable in self.queue.async { - self.stopLock.withWriteLock { - self.streamSubject.onCompleted() - self.cleanUpAndCloseSocket() + self.streamSubject.onCompleted() + self.cleanUpAndCloseSocket() - completable(.completed) - } + completable(.completed) } return Disposables.create() } @@ -121,14 +104,10 @@ public final class RxMsgpackRpc { params: [Value], expectsReturnValue: Bool ) -> Single { - - return Single.create { single in + Single.create { single in self.queue.async { - let msgid: UInt32 = self.nextMsgidLock.withLock { - let result = self.nextMsgid - self.nextMsgid += 1 - return result - } + let msgid = self.nextMsgid + self.nextMsgid += 1 let packed = pack( [ @@ -139,50 +118,42 @@ public final class RxMsgpackRpc { ] ) - self.stopLock.withReadLock { - if self.stopped { - single(.error(Error(msg: "Connection stopped, " + - "but trying to send a request with msg id \(msgid)"))) - return - } + if self.stopped { + single(.error(Error(msg: "Connection stopped, " + + "but trying to send a request with msg id \(msgid)"))) + return + } - guard let socket = self.socket else { - single(.error(Error(msg: "Socket is invalid, " + - "but trying to send a request with msg id \(msgid)"))) - return - } + guard let socket = self.socket else { + single(.error(Error(msg: "Socket is invalid, " + + "but trying to send a request with msg id \(msgid)"))) + return + } - if expectsReturnValue { - self.singlesLock.withLock { - self.singles[msgid] = single - } - } - - do { - let writtenBytes = try socket.write(from: packed) - if writtenBytes < packed.count { - single(.error(Error( - msg: "(Written) = \(writtenBytes) < \(packed.count) = " + - "(requested) for msg id: \(msgid)" - ))) - - return - } - } catch { - self.streamSubject.onError(Error( - msg: "Could not write to socket for msg id: " + - "\(msgid)", cause: error)) + if expectsReturnValue { self.singles[msgid] = single } + do { + let writtenBytes = try socket.write(from: packed) + if writtenBytes < packed.count { single(.error(Error( - msg: "Could not write to socket for msg id: " + - "\(msgid)", cause: error))) + msg: "(Written) = \(writtenBytes) < \(packed.count) = " + + "(requested) for msg id: \(msgid)" + ))) return } + } catch { + self.streamSubject.onError(Error( + msg: "Could not write to socket for msg id: \(msgid)", cause: error)) - if !expectsReturnValue { - single(.success(self.nilResponse(with: msgid))) - } + single(.error(Error( + msg: "Could not write to socket for msg id: \(msgid)", cause: error))) + + return + } + + if !expectsReturnValue { + single(.success(self.nilResponse(with: msgid))) } } @@ -190,27 +161,27 @@ public final class RxMsgpackRpc { } } + // MARK: - Private private var nextMsgid: UInt32 = 0 - private let nextMsgidLock = NSLock() + + private var socket: Socket? + private var thread: Thread? + private let queue = DispatchQueue( + label: String(reflecting: RxMsgpackRpc.self), + qos: .userInitiated + ) private var stopped = true - private let stopLock = ReadersWriterLock() + private var singles: [UInt32: SingleResponseObserver] = [:] private let streamSubject = PublishSubject() - private var singles: [UInt32: SingleResponseObserver] = [:] - private let singlesLock = NSLock() - private func nilResponse(with msgid: UInt32) -> Response { - return Response(msgid: msgid, error: .nil, result: .nil) + Response(msgid: msgid, error: .nil, result: .nil) } private func cleanUpAndCloseSocket() { - self.singlesLock.withLock { - self.singles.forEach { msgid, single in - single(.success(self.nilResponse(with: msgid))) - } - } + self.singles.forEach { msgid, single in single(.success(self.nilResponse(with: msgid))) } self.singles.removeAll() self.stopped = true @@ -219,9 +190,7 @@ public final class RxMsgpackRpc { private func setUpThreadAndStartReading() { self.thread = Thread { - guard let socket = self.socket else { - return - } + guard let socket = self.socket else { return } var readData = Data(capacity: 10240) repeat { @@ -233,11 +202,8 @@ public final class RxMsgpackRpc { values.forEach(self.processMessage) } } catch let error as Socket.Error { - self.streamSubject.onError(Error( - msg: "Could not read from socket", cause: error) - ) - // No need to lock since we are currently trying to open the socket. - self.cleanUpAndCloseSocket() + self.streamSubject.onError(Error(msg: "Could not read from socket", cause: error)) + self.queue.async { self.cleanUpAndCloseSocket() } return } catch { self.streamSubject.onNext( @@ -274,31 +240,25 @@ public final class RxMsgpackRpc { guard array.count == 4 else { self.streamSubject.onNext(.error( value: unpacked, - msg: "Got an array of length \(array.count) " + - "for a message type response" + msg: "Got an array of length \(array.count) for a message type response" )) return } guard let msgid64 = array[1].uint64Value else { - self.streamSubject.onNext(.error( - value: unpacked, - msg: "Could not get the msgid" - )) + self.streamSubject.onNext(.error(value: unpacked, msg: "Could not get the msgid")) return } - self.processResponse( - msgid: UInt32(msgid64), - error: array[2], - result: array[3] - ) + + self.queue.async { + self.processResponse(msgid: UInt32(msgid64), error: array[2], result: array[3]) + } case .notification: guard array.count == 3 else { self.streamSubject.onNext(.error( value: unpacked, - msg: "Got an array of length \(array.count) " + - "for a message type notification" + msg: "Got an array of length \(array.count) for a message type notification" )) return @@ -327,34 +287,14 @@ public final class RxMsgpackRpc { private func processResponse(msgid: UInt32, error: Value, result: Value) { if self.streamResponses { - self.streamSubject.onNext(.response( - msgid: msgid, - error: error, - result: result - )) + self.streamSubject.onNext(.response(msgid: msgid, error: error, result: result)) } - guard let single: SingleResponseObserver = self.singlesLock.withLock({ - let s = self.singles[msgid] - self.singles.removeValue(forKey: msgid) - return s - }) else { - return - } + guard let single: SingleResponseObserver = self.singles[msgid] else { return } single(.success(Response(msgid: msgid, error: error, result: result))) + self.singles.removeValue(forKey: msgid) } } -private typealias SingleResponseObserver - = (SingleEvent) -> Void - -fileprivate extension NSLocking { - - @discardableResult - func withLock(_ body: () -> T) -> T { - self.lock() - defer { self.unlock() } - return body() - } -} +private typealias SingleResponseObserver = (SingleEvent) -> Void diff --git a/RxPack/RxNeovimApi.generated.swift b/RxPack/RxNeovimApi.generated.swift index e5636b7b..dff4a2fa 100644 --- a/RxPack/RxNeovimApi.generated.swift +++ b/RxPack/RxNeovimApi.generated.swift @@ -43,7 +43,7 @@ extension RxNeovimApi { func bufLineCount( buffer: RxNeovimApi.Buffer, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -58,7 +58,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_line_count", params: params, expectsReturnValue: true) @@ -75,7 +75,7 @@ extension RxNeovimApi { buffer: RxNeovimApi.Buffer, send_buffer: Bool, opts: Dictionary, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -92,7 +92,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_attach", params: params, expectsReturnValue: true) @@ -107,7 +107,7 @@ extension RxNeovimApi { func bufDetach( buffer: RxNeovimApi.Buffer, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -122,7 +122,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_detach", params: params, expectsReturnValue: true) @@ -140,7 +140,7 @@ extension RxNeovimApi { start: Int, end: Int, strict_indexing: Bool, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[String]> { let params: [RxNeovimApi.Value] = [ @@ -158,7 +158,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_lines", params: params, expectsReturnValue: true) @@ -177,8 +177,7 @@ extension RxNeovimApi { end: Int, strict_indexing: Bool, replacement: [String], - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -189,7 +188,7 @@ extension RxNeovimApi { .array(replacement.map { .string($0) }), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_buf_set_lines", params: params, expectsReturnValue: expectsReturnValue) @@ -205,7 +204,7 @@ extension RxNeovimApi { func bufGetOffset( buffer: RxNeovimApi.Buffer, index: Int, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -221,7 +220,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_offset", params: params, expectsReturnValue: true) @@ -237,7 +236,7 @@ extension RxNeovimApi { func bufGetVar( buffer: RxNeovimApi.Buffer, name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -253,7 +252,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_var", params: params, expectsReturnValue: true) @@ -268,7 +267,7 @@ extension RxNeovimApi { func bufGetChangedtick( buffer: RxNeovimApi.Buffer, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -283,7 +282,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_changedtick", params: params, expectsReturnValue: true) @@ -299,7 +298,7 @@ extension RxNeovimApi { func bufGetKeymap( buffer: RxNeovimApi.Buffer, mode: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[Dictionary]> { let params: [RxNeovimApi.Value] = [ @@ -315,7 +314,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_keymap", params: params, expectsReturnValue: true) @@ -334,8 +333,7 @@ extension RxNeovimApi { lhs: String, rhs: String, opts: Dictionary, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -346,7 +344,7 @@ extension RxNeovimApi { .map(opts.mapToDict({ (Value.string($0), $1) })), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_buf_set_keymap", params: params, expectsReturnValue: expectsReturnValue) @@ -363,8 +361,7 @@ extension RxNeovimApi { buffer: RxNeovimApi.Buffer, mode: String, lhs: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -373,7 +370,7 @@ extension RxNeovimApi { .string(lhs), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_buf_del_keymap", params: params, expectsReturnValue: expectsReturnValue) @@ -389,7 +386,7 @@ extension RxNeovimApi { func bufGetCommands( buffer: RxNeovimApi.Buffer, opts: Dictionary, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -405,7 +402,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_commands", params: params, expectsReturnValue: true) @@ -422,8 +419,7 @@ extension RxNeovimApi { buffer: RxNeovimApi.Buffer, name: String, value: RxNeovimApi.Value, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -432,7 +428,7 @@ extension RxNeovimApi { value, ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_buf_set_var", params: params, expectsReturnValue: expectsReturnValue) @@ -448,8 +444,7 @@ extension RxNeovimApi { func bufDelVar( buffer: RxNeovimApi.Buffer, name: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -457,7 +452,7 @@ extension RxNeovimApi { .string(name), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_buf_del_var", params: params, expectsReturnValue: expectsReturnValue) @@ -473,7 +468,7 @@ extension RxNeovimApi { func bufGetOption( buffer: RxNeovimApi.Buffer, name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -489,7 +484,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_option", params: params, expectsReturnValue: true) @@ -506,8 +501,7 @@ extension RxNeovimApi { buffer: RxNeovimApi.Buffer, name: String, value: RxNeovimApi.Value, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -516,7 +510,7 @@ extension RxNeovimApi { value, ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_buf_set_option", params: params, expectsReturnValue: expectsReturnValue) @@ -531,7 +525,7 @@ extension RxNeovimApi { func bufGetName( buffer: RxNeovimApi.Buffer, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -546,7 +540,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_name", params: params, expectsReturnValue: true) @@ -562,8 +556,7 @@ extension RxNeovimApi { func bufSetName( buffer: RxNeovimApi.Buffer, name: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -571,7 +564,7 @@ extension RxNeovimApi { .string(name), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_buf_set_name", params: params, expectsReturnValue: expectsReturnValue) @@ -586,7 +579,7 @@ extension RxNeovimApi { func bufIsLoaded( buffer: RxNeovimApi.Buffer, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -601,7 +594,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_is_loaded", params: params, expectsReturnValue: true) @@ -616,7 +609,7 @@ extension RxNeovimApi { func bufIsValid( buffer: RxNeovimApi.Buffer, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -631,7 +624,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_is_valid", params: params, expectsReturnValue: true) @@ -647,7 +640,7 @@ extension RxNeovimApi { func bufGetMark( buffer: RxNeovimApi.Buffer, name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[Int]> { let params: [RxNeovimApi.Value] = [ @@ -663,7 +656,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_mark", params: params, expectsReturnValue: true) @@ -680,7 +673,7 @@ extension RxNeovimApi { buffer: RxNeovimApi.Buffer, ns_id: Int, id: Int, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[Int]> { let params: [RxNeovimApi.Value] = [ @@ -697,7 +690,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_extmark_by_id", params: params, expectsReturnValue: true) @@ -716,7 +709,7 @@ extension RxNeovimApi { start: RxNeovimApi.Value, end: RxNeovimApi.Value, opts: Dictionary, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -735,7 +728,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_extmarks", params: params, expectsReturnValue: true) @@ -755,7 +748,7 @@ extension RxNeovimApi { line: Int, col: Int, opts: Dictionary, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -775,7 +768,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_set_extmark", params: params, expectsReturnValue: true) @@ -792,7 +785,7 @@ extension RxNeovimApi { buffer: RxNeovimApi.Buffer, ns_id: Int, id: Int, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -809,7 +802,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_del_extmark", params: params, expectsReturnValue: true) @@ -829,7 +822,7 @@ extension RxNeovimApi { line: Int, col_start: Int, col_end: Int, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -849,7 +842,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_add_highlight", params: params, expectsReturnValue: true) @@ -867,8 +860,7 @@ extension RxNeovimApi { ns_id: Int, line_start: Int, line_end: Int, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -878,7 +870,7 @@ extension RxNeovimApi { .int(Int64(line_end)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_buf_clear_namespace", params: params, expectsReturnValue: expectsReturnValue) @@ -896,8 +888,7 @@ extension RxNeovimApi { ns_id: Int, line_start: Int, line_end: Int, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -907,7 +898,7 @@ extension RxNeovimApi { .int(Int64(line_end)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_buf_clear_highlight", params: params, expectsReturnValue: expectsReturnValue) @@ -926,7 +917,7 @@ extension RxNeovimApi { line: Int, chunks: RxNeovimApi.Value, opts: Dictionary, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -945,7 +936,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_set_virtual_text", params: params, expectsReturnValue: true) @@ -961,7 +952,7 @@ extension RxNeovimApi { func bufGetVirtualText( buffer: RxNeovimApi.Buffer, line: Int, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -977,7 +968,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_buf_get_virtual_text", params: params, expectsReturnValue: true) @@ -992,7 +983,7 @@ extension RxNeovimApi { func tabpageListWins( tabpage: RxNeovimApi.Tabpage, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Window]> { let params: [RxNeovimApi.Value] = [ @@ -1007,7 +998,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_tabpage_list_wins", params: params, expectsReturnValue: true) @@ -1023,7 +1014,7 @@ extension RxNeovimApi { func tabpageGetVar( tabpage: RxNeovimApi.Tabpage, name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1039,7 +1030,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_tabpage_get_var", params: params, expectsReturnValue: true) @@ -1056,8 +1047,7 @@ extension RxNeovimApi { tabpage: RxNeovimApi.Tabpage, name: String, value: RxNeovimApi.Value, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -1066,7 +1056,7 @@ extension RxNeovimApi { value, ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_tabpage_set_var", params: params, expectsReturnValue: expectsReturnValue) @@ -1082,8 +1072,7 @@ extension RxNeovimApi { func tabpageDelVar( tabpage: RxNeovimApi.Tabpage, name: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -1091,7 +1080,7 @@ extension RxNeovimApi { .string(name), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_tabpage_del_var", params: params, expectsReturnValue: expectsReturnValue) @@ -1106,7 +1095,7 @@ extension RxNeovimApi { func tabpageGetWin( tabpage: RxNeovimApi.Tabpage, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1121,7 +1110,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_tabpage_get_win", params: params, expectsReturnValue: true) @@ -1136,7 +1125,7 @@ extension RxNeovimApi { func tabpageGetNumber( tabpage: RxNeovimApi.Tabpage, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1151,7 +1140,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_tabpage_get_number", params: params, expectsReturnValue: true) @@ -1166,7 +1155,7 @@ extension RxNeovimApi { func tabpageIsValid( tabpage: RxNeovimApi.Tabpage, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1181,7 +1170,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_tabpage_is_valid", params: params, expectsReturnValue: true) @@ -1198,8 +1187,7 @@ extension RxNeovimApi { width: Int, height: Int, options: Dictionary, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -1208,7 +1196,7 @@ extension RxNeovimApi { .map(options.mapToDict({ (Value.string($0), $1) })), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_ui_attach", params: params, expectsReturnValue: expectsReturnValue) @@ -1222,15 +1210,14 @@ extension RxNeovimApi { } func uiDetach( - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_ui_detach", params: params, expectsReturnValue: expectsReturnValue) @@ -1246,8 +1233,7 @@ extension RxNeovimApi { func uiTryResize( width: Int, height: Int, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -1255,7 +1241,7 @@ extension RxNeovimApi { .int(Int64(height)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_ui_try_resize", params: params, expectsReturnValue: expectsReturnValue) @@ -1271,8 +1257,7 @@ extension RxNeovimApi { func uiSetOption( name: String, value: RxNeovimApi.Value, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -1280,7 +1265,7 @@ extension RxNeovimApi { value, ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_ui_set_option", params: params, expectsReturnValue: expectsReturnValue) @@ -1297,8 +1282,7 @@ extension RxNeovimApi { grid: Int, width: Int, height: Int, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -1307,7 +1291,7 @@ extension RxNeovimApi { .int(Int64(height)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_ui_try_resize_grid", params: params, expectsReturnValue: expectsReturnValue) @@ -1322,15 +1306,14 @@ extension RxNeovimApi { func uiPumSetHeight( height: Int, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .int(Int64(height)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_ui_pum_set_height", params: params, expectsReturnValue: expectsReturnValue) @@ -1346,7 +1329,7 @@ extension RxNeovimApi { func exec( src: String, output: Bool, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1362,7 +1345,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_exec", params: params, expectsReturnValue: true) @@ -1377,15 +1360,14 @@ extension RxNeovimApi { func command( command: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .string(command), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_command", params: params, expectsReturnValue: expectsReturnValue) @@ -1401,7 +1383,7 @@ extension RxNeovimApi { func getHlByName( name: String, rgb: Bool, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -1417,7 +1399,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_hl_by_name", params: params, expectsReturnValue: true) @@ -1433,7 +1415,7 @@ extension RxNeovimApi { func getHlById( hl_id: Int, rgb: Bool, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -1449,7 +1431,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_hl_by_id", params: params, expectsReturnValue: true) @@ -1464,7 +1446,7 @@ extension RxNeovimApi { func getHlIdByName( name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1479,7 +1461,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_hl_id_by_name", params: params, expectsReturnValue: true) @@ -1496,8 +1478,7 @@ extension RxNeovimApi { keys: String, mode: String, escape_csi: Bool, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -1506,7 +1487,7 @@ extension RxNeovimApi { .bool(escape_csi), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_feedkeys", params: params, expectsReturnValue: expectsReturnValue) @@ -1521,7 +1502,7 @@ extension RxNeovimApi { func input( keys: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1536,7 +1517,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_input", params: params, expectsReturnValue: true) @@ -1556,8 +1537,7 @@ extension RxNeovimApi { grid: Int, row: Int, col: Int, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -1569,7 +1549,7 @@ extension RxNeovimApi { .int(Int64(col)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_input_mouse", params: params, expectsReturnValue: expectsReturnValue) @@ -1587,7 +1567,7 @@ extension RxNeovimApi { from_part: Bool, do_lt: Bool, special: Bool, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1605,7 +1585,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_replace_termcodes", params: params, expectsReturnValue: true) @@ -1620,7 +1600,7 @@ extension RxNeovimApi { func eval( expr: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1635,7 +1615,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_eval", params: params, expectsReturnValue: true) @@ -1651,7 +1631,7 @@ extension RxNeovimApi { func execLua( code: String, args: RxNeovimApi.Value, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1667,7 +1647,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_exec_lua", params: params, expectsReturnValue: true) @@ -1683,7 +1663,7 @@ extension RxNeovimApi { func callFunction( fn: String, args: RxNeovimApi.Value, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1699,7 +1679,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_call_function", params: params, expectsReturnValue: true) @@ -1716,7 +1696,7 @@ extension RxNeovimApi { dict: RxNeovimApi.Value, fn: String, args: RxNeovimApi.Value, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1733,7 +1713,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_call_dict_function", params: params, expectsReturnValue: true) @@ -1748,7 +1728,7 @@ extension RxNeovimApi { func strwidth( text: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1763,7 +1743,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_strwidth", params: params, expectsReturnValue: true) @@ -1777,7 +1757,7 @@ extension RxNeovimApi { } func listRuntimePaths( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[String]> { let params: [RxNeovimApi.Value] = [ @@ -1792,7 +1772,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_list_runtime_paths", params: params, expectsReturnValue: true) @@ -1807,15 +1787,14 @@ extension RxNeovimApi { func setCurrentDir( dir: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .string(dir), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_set_current_dir", params: params, expectsReturnValue: expectsReturnValue) @@ -1829,7 +1808,7 @@ extension RxNeovimApi { } func getCurrentLine( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1844,7 +1823,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_current_line", params: params, expectsReturnValue: true) @@ -1859,15 +1838,14 @@ extension RxNeovimApi { func setCurrentLine( line: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .string(line), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_set_current_line", params: params, expectsReturnValue: expectsReturnValue) @@ -1881,15 +1859,14 @@ extension RxNeovimApi { } func delCurrentLine( - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_del_current_line", params: params, expectsReturnValue: expectsReturnValue) @@ -1904,7 +1881,7 @@ extension RxNeovimApi { func getVar( name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1919,7 +1896,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_var", params: params, expectsReturnValue: true) @@ -1935,8 +1912,7 @@ extension RxNeovimApi { func setVar( name: String, value: RxNeovimApi.Value, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -1944,7 +1920,7 @@ extension RxNeovimApi { value, ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_set_var", params: params, expectsReturnValue: expectsReturnValue) @@ -1959,15 +1935,14 @@ extension RxNeovimApi { func delVar( name: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .string(name), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_del_var", params: params, expectsReturnValue: expectsReturnValue) @@ -1982,7 +1957,7 @@ extension RxNeovimApi { func getVvar( name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -1997,7 +1972,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_vvar", params: params, expectsReturnValue: true) @@ -2013,8 +1988,7 @@ extension RxNeovimApi { func setVvar( name: String, value: RxNeovimApi.Value, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -2022,7 +1996,7 @@ extension RxNeovimApi { value, ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_set_vvar", params: params, expectsReturnValue: expectsReturnValue) @@ -2037,7 +2011,7 @@ extension RxNeovimApi { func getOption( name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2052,7 +2026,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_option", params: params, expectsReturnValue: true) @@ -2068,8 +2042,7 @@ extension RxNeovimApi { func setOption( name: String, value: RxNeovimApi.Value, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -2077,7 +2050,7 @@ extension RxNeovimApi { value, ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_set_option", params: params, expectsReturnValue: expectsReturnValue) @@ -2092,15 +2065,14 @@ extension RxNeovimApi { func outWrite( str: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .string(str), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_out_write", params: params, expectsReturnValue: expectsReturnValue) @@ -2115,15 +2087,14 @@ extension RxNeovimApi { func errWrite( str: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .string(str), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_err_write", params: params, expectsReturnValue: expectsReturnValue) @@ -2138,15 +2109,14 @@ extension RxNeovimApi { func errWriteln( str: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .string(str), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_err_writeln", params: params, expectsReturnValue: expectsReturnValue) @@ -2160,7 +2130,7 @@ extension RxNeovimApi { } func listBufs( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Buffer]> { let params: [RxNeovimApi.Value] = [ @@ -2175,7 +2145,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_list_bufs", params: params, expectsReturnValue: true) @@ -2189,7 +2159,7 @@ extension RxNeovimApi { } func getCurrentBuf( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2204,7 +2174,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_current_buf", params: params, expectsReturnValue: true) @@ -2219,15 +2189,14 @@ extension RxNeovimApi { func setCurrentBuf( buffer: RxNeovimApi.Buffer, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .int(Int64(buffer.handle)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_set_current_buf", params: params, expectsReturnValue: expectsReturnValue) @@ -2241,7 +2210,7 @@ extension RxNeovimApi { } func listWins( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Window]> { let params: [RxNeovimApi.Value] = [ @@ -2256,7 +2225,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_list_wins", params: params, expectsReturnValue: true) @@ -2270,7 +2239,7 @@ extension RxNeovimApi { } func getCurrentWin( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2285,7 +2254,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_current_win", params: params, expectsReturnValue: true) @@ -2300,15 +2269,14 @@ extension RxNeovimApi { func setCurrentWin( window: RxNeovimApi.Window, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .int(Int64(window.handle)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_set_current_win", params: params, expectsReturnValue: expectsReturnValue) @@ -2324,7 +2292,7 @@ extension RxNeovimApi { func createBuf( listed: Bool, scratch: Bool, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2340,7 +2308,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_create_buf", params: params, expectsReturnValue: true) @@ -2357,7 +2325,7 @@ extension RxNeovimApi { buffer: RxNeovimApi.Buffer, enter: Bool, config: Dictionary, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2374,7 +2342,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_open_win", params: params, expectsReturnValue: true) @@ -2388,7 +2356,7 @@ extension RxNeovimApi { } func listTabpages( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Tabpage]> { let params: [RxNeovimApi.Value] = [ @@ -2403,7 +2371,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_list_tabpages", params: params, expectsReturnValue: true) @@ -2417,7 +2385,7 @@ extension RxNeovimApi { } func getCurrentTabpage( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2432,7 +2400,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_current_tabpage", params: params, expectsReturnValue: true) @@ -2447,15 +2415,14 @@ extension RxNeovimApi { func setCurrentTabpage( tabpage: RxNeovimApi.Tabpage, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .int(Int64(tabpage.handle)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_set_current_tabpage", params: params, expectsReturnValue: expectsReturnValue) @@ -2470,7 +2437,7 @@ extension RxNeovimApi { func createNamespace( name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2485,7 +2452,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_create_namespace", params: params, expectsReturnValue: true) @@ -2499,7 +2466,7 @@ extension RxNeovimApi { } func getNamespaces( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -2514,7 +2481,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_namespaces", params: params, expectsReturnValue: true) @@ -2531,7 +2498,7 @@ extension RxNeovimApi { data: String, crlf: Bool, phase: Int, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2548,7 +2515,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_paste", params: params, expectsReturnValue: true) @@ -2566,8 +2533,7 @@ extension RxNeovimApi { type: String, after: Bool, follow: Bool, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -2577,7 +2543,7 @@ extension RxNeovimApi { .bool(follow), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_put", params: params, expectsReturnValue: expectsReturnValue) @@ -2592,15 +2558,14 @@ extension RxNeovimApi { func subscribe( event: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .string(event), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_subscribe", params: params, expectsReturnValue: expectsReturnValue) @@ -2615,15 +2580,14 @@ extension RxNeovimApi { func unsubscribe( event: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ .string(event), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_unsubscribe", params: params, expectsReturnValue: expectsReturnValue) @@ -2638,7 +2602,7 @@ extension RxNeovimApi { func getColorByName( name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2653,7 +2617,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_color_by_name", params: params, expectsReturnValue: true) @@ -2667,7 +2631,7 @@ extension RxNeovimApi { } func getColorMap( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -2682,7 +2646,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_color_map", params: params, expectsReturnValue: true) @@ -2697,7 +2661,7 @@ extension RxNeovimApi { func getContext( opts: Dictionary, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -2712,7 +2676,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_context", params: params, expectsReturnValue: true) @@ -2727,7 +2691,7 @@ extension RxNeovimApi { func loadContext( dict: Dictionary, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2742,7 +2706,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_load_context", params: params, expectsReturnValue: true) @@ -2774,7 +2738,7 @@ extension RxNeovimApi { func getKeymap( mode: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[Dictionary]> { let params: [RxNeovimApi.Value] = [ @@ -2789,7 +2753,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_keymap", params: params, expectsReturnValue: true) @@ -2807,8 +2771,7 @@ extension RxNeovimApi { lhs: String, rhs: String, opts: Dictionary, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -2818,7 +2781,7 @@ extension RxNeovimApi { .map(opts.mapToDict({ (Value.string($0), $1) })), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_set_keymap", params: params, expectsReturnValue: expectsReturnValue) @@ -2834,8 +2797,7 @@ extension RxNeovimApi { func delKeymap( mode: String, lhs: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -2843,7 +2805,7 @@ extension RxNeovimApi { .string(lhs), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_del_keymap", params: params, expectsReturnValue: expectsReturnValue) @@ -2858,7 +2820,7 @@ extension RxNeovimApi { func getCommands( opts: Dictionary, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -2873,7 +2835,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_commands", params: params, expectsReturnValue: true) @@ -2887,7 +2849,7 @@ extension RxNeovimApi { } func getApiInfo( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2902,7 +2864,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_api_info", params: params, expectsReturnValue: true) @@ -2921,8 +2883,7 @@ extension RxNeovimApi { type: String, methods: Dictionary, attributes: Dictionary, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -2933,7 +2894,7 @@ extension RxNeovimApi { .map(attributes.mapToDict({ (Value.string($0), $1) })), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_set_client_info", params: params, expectsReturnValue: expectsReturnValue) @@ -2948,7 +2909,7 @@ extension RxNeovimApi { func getChanInfo( chan: Int, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -2963,7 +2924,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_chan_info", params: params, expectsReturnValue: true) @@ -2977,7 +2938,7 @@ extension RxNeovimApi { } func listChans( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -2992,7 +2953,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_list_chans", params: params, expectsReturnValue: true) @@ -3007,7 +2968,7 @@ extension RxNeovimApi { func callAtomic( calls: RxNeovimApi.Value, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3022,7 +2983,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_call_atomic", params: params, expectsReturnValue: true) @@ -3039,7 +3000,7 @@ extension RxNeovimApi { expr: String, flags: String, highlight: Bool, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -3056,7 +3017,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_parse_expression", params: params, expectsReturnValue: true) @@ -3070,7 +3031,7 @@ extension RxNeovimApi { } func listUis( - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3085,7 +3046,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_list_uis", params: params, expectsReturnValue: true) @@ -3100,7 +3061,7 @@ extension RxNeovimApi { func getProcChildren( pid: Int, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3115,7 +3076,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_proc_children", params: params, expectsReturnValue: true) @@ -3130,7 +3091,7 @@ extension RxNeovimApi { func getProc( pid: Int, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3145,7 +3106,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_get_proc", params: params, expectsReturnValue: true) @@ -3163,8 +3124,7 @@ extension RxNeovimApi { insert: Bool, finish: Bool, opts: Dictionary, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -3174,7 +3134,7 @@ extension RxNeovimApi { .map(opts.mapToDict({ (Value.string($0), $1) })), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_select_popupmenu_item", params: params, expectsReturnValue: expectsReturnValue) @@ -3189,7 +3149,7 @@ extension RxNeovimApi { func winGetBuf( window: RxNeovimApi.Window, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3204,7 +3164,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_get_buf", params: params, expectsReturnValue: true) @@ -3220,8 +3180,7 @@ extension RxNeovimApi { func winSetBuf( window: RxNeovimApi.Window, buffer: RxNeovimApi.Buffer, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -3229,7 +3188,7 @@ extension RxNeovimApi { .int(Int64(buffer.handle)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_win_set_buf", params: params, expectsReturnValue: expectsReturnValue) @@ -3244,7 +3203,7 @@ extension RxNeovimApi { func winGetCursor( window: RxNeovimApi.Window, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[Int]> { let params: [RxNeovimApi.Value] = [ @@ -3259,7 +3218,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_get_cursor", params: params, expectsReturnValue: true) @@ -3275,8 +3234,7 @@ extension RxNeovimApi { func winSetCursor( window: RxNeovimApi.Window, pos: [Int], - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -3284,7 +3242,7 @@ extension RxNeovimApi { .array(pos.map { .int(Int64($0)) }), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_win_set_cursor", params: params, expectsReturnValue: expectsReturnValue) @@ -3299,7 +3257,7 @@ extension RxNeovimApi { func winGetHeight( window: RxNeovimApi.Window, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3314,7 +3272,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_get_height", params: params, expectsReturnValue: true) @@ -3330,8 +3288,7 @@ extension RxNeovimApi { func winSetHeight( window: RxNeovimApi.Window, height: Int, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -3339,7 +3296,7 @@ extension RxNeovimApi { .int(Int64(height)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_win_set_height", params: params, expectsReturnValue: expectsReturnValue) @@ -3354,7 +3311,7 @@ extension RxNeovimApi { func winGetWidth( window: RxNeovimApi.Window, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3369,7 +3326,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_get_width", params: params, expectsReturnValue: true) @@ -3385,8 +3342,7 @@ extension RxNeovimApi { func winSetWidth( window: RxNeovimApi.Window, width: Int, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -3394,7 +3350,7 @@ extension RxNeovimApi { .int(Int64(width)), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_win_set_width", params: params, expectsReturnValue: expectsReturnValue) @@ -3410,7 +3366,7 @@ extension RxNeovimApi { func winGetVar( window: RxNeovimApi.Window, name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3426,7 +3382,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_get_var", params: params, expectsReturnValue: true) @@ -3443,8 +3399,7 @@ extension RxNeovimApi { window: RxNeovimApi.Window, name: String, value: RxNeovimApi.Value, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -3453,7 +3408,7 @@ extension RxNeovimApi { value, ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_win_set_var", params: params, expectsReturnValue: expectsReturnValue) @@ -3469,8 +3424,7 @@ extension RxNeovimApi { func winDelVar( window: RxNeovimApi.Window, name: String, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -3478,7 +3432,7 @@ extension RxNeovimApi { .string(name), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_win_del_var", params: params, expectsReturnValue: expectsReturnValue) @@ -3494,7 +3448,7 @@ extension RxNeovimApi { func winGetOption( window: RxNeovimApi.Window, name: String, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3510,7 +3464,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_get_option", params: params, expectsReturnValue: true) @@ -3527,8 +3481,7 @@ extension RxNeovimApi { window: RxNeovimApi.Window, name: String, value: RxNeovimApi.Value, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -3537,7 +3490,7 @@ extension RxNeovimApi { value, ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_win_set_option", params: params, expectsReturnValue: expectsReturnValue) @@ -3552,7 +3505,7 @@ extension RxNeovimApi { func winGetPosition( window: RxNeovimApi.Window, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<[Int]> { let params: [RxNeovimApi.Value] = [ @@ -3567,7 +3520,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_get_position", params: params, expectsReturnValue: true) @@ -3582,7 +3535,7 @@ extension RxNeovimApi { func winGetTabpage( window: RxNeovimApi.Window, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3597,7 +3550,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_get_tabpage", params: params, expectsReturnValue: true) @@ -3612,7 +3565,7 @@ extension RxNeovimApi { func winGetNumber( window: RxNeovimApi.Window, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3627,7 +3580,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_get_number", params: params, expectsReturnValue: true) @@ -3642,7 +3595,7 @@ extension RxNeovimApi { func winIsValid( window: RxNeovimApi.Window, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single { let params: [RxNeovimApi.Value] = [ @@ -3657,7 +3610,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_is_valid", params: params, expectsReturnValue: true) @@ -3673,8 +3626,7 @@ extension RxNeovimApi { func winSetConfig( window: RxNeovimApi.Window, config: Dictionary, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -3682,7 +3634,7 @@ extension RxNeovimApi { .map(config.mapToDict({ (Value.string($0), $1) })), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_win_set_config", params: params, expectsReturnValue: expectsReturnValue) @@ -3697,7 +3649,7 @@ extension RxNeovimApi { func winGetConfig( window: RxNeovimApi.Window, - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single> { let params: [RxNeovimApi.Value] = [ @@ -3712,7 +3664,7 @@ extension RxNeovimApi { return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "nvim_win_get_config", params: params, expectsReturnValue: true) @@ -3728,8 +3680,7 @@ extension RxNeovimApi { func winClose( window: RxNeovimApi.Window, force: Bool, - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ @@ -3737,7 +3688,7 @@ extension RxNeovimApi { .bool(force), ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "nvim_win_close", params: params, expectsReturnValue: expectsReturnValue) diff --git a/RxPack/RxNeovimApi.swift b/RxPack/RxNeovimApi.swift index 108b6781..79609961 100644 --- a/RxPack/RxNeovimApi.swift +++ b/RxPack/RxNeovimApi.swift @@ -15,87 +15,51 @@ public final class RxNeovimApi { public struct Buffer: Equatable { - public static func ==(lhs: Buffer, rhs: Buffer) -> Bool { - return lhs.handle == rhs.handle - } + public static func ==(lhs: Buffer, rhs: Buffer) -> Bool { lhs.handle == rhs.handle } public let handle: Int - public init(_ handle: Int) { - self.handle = handle - } + public init(_ handle: Int) { self.handle = handle } } public struct Window: Equatable { - public static func ==(lhs: Window, rhs: Window) -> Bool { - return lhs.handle == rhs.handle - } + public static func ==(lhs: Window, rhs: Window) -> Bool { lhs.handle == rhs.handle } public let handle: Int - public init(_ handle: Int) { - self.handle = handle - } + public init(_ handle: Int) { self.handle = handle } } public struct Tabpage: Equatable { - public static func ==(lhs: Tabpage, rhs: Tabpage) -> Bool { - return lhs.handle == rhs.handle - } + public static func ==(lhs: Tabpage, rhs: Tabpage) -> Bool { lhs.handle == rhs.handle } public let handle: Int - public init(_ handle: Int) { - self.handle = handle - } + public init(_ handle: Int) { self.handle = handle } } public typealias Value = RxMsgpackRpc.Value public var streamResponses: Bool { - get { - return self.msgpackRpc.streamResponses - } - set { - self.msgpackRpc.streamResponses = newValue - } + get { self.msgpackRpc.streamResponses } + set { self.msgpackRpc.streamResponses = newValue } } public var streamRawResponses: Bool { - get { - return self.msgpackRpc.streamResponses - } - set { - self.msgpackRpc.streamResponses = newValue - } + get { self.msgpackRpc.streamResponses } + set { self.msgpackRpc.streamResponses = newValue } } - public var msgpackRawStream: Observable { - return self.msgpackRpc.stream - } + public var msgpackRawStream: Observable { self.msgpackRpc.stream } - public var queue = DispatchQueue(label: String(reflecting: RxNeovimApi.self), qos: .userInitiated) { - didSet { - self.msgpackRpc.queue = self.queue - } - } + public func run(at path: String) -> Completable { self.msgpackRpc.run(at: path) } - public init() { - self.msgpackRpc.queue = self.queue - } - - public func run(at path: String) -> Completable { - return self.msgpackRpc.run(at: path) - } - - public func stop() -> Completable { - return self.msgpackRpc.stop() - } + public func stop() -> Completable { self.msgpackRpc.stop() } public func checkBlocked(_ single: Single) -> Single { - return self + self .getMode() .flatMap { dict -> Single in guard (dict["blocking"]?.boolValue ?? false) == false else { @@ -106,30 +70,24 @@ public final class RxNeovimApi { } } - public func rpc(method: String, - params: [RxNeovimApi.Value], - expectsReturnValue: Bool = true) -> Single { - - return self.msgpackRpc + public func rpc( + method: String, + params: [RxNeovimApi.Value], + expectsReturnValue: Bool = true + ) -> Single { + self.msgpackRpc .request(method: method, params: params, expectsReturnValue: expectsReturnValue) .map { response -> RxMsgpackRpc.Value in - guard response.error.isNil else { - throw RxNeovimApi.Error(response.error) - } + guard response.error.isNil else { throw RxNeovimApi.Error(response.error) } return response.result } } private let msgpackRpc = RxMsgpackRpc() -} -fileprivate extension NSLocking { - - @discardableResult - func withLock(_ body: () -> T) -> T { - self.lock() - defer { self.unlock() } - return body() - } + private let queue = DispatchQueue( + label: String(reflecting: RxNeovimApi.self), + qos: .userInitiated + ) } diff --git a/RxPack/RxNeovimApiTests/RxNeovimApiTests.swift b/RxPack/RxNeovimApiTests/RxNeovimApiTests.swift index b20268b4..ff1ba4f5 100644 --- a/RxPack/RxNeovimApiTests/RxNeovimApiTests.swift +++ b/RxPack/RxNeovimApiTests/RxNeovimApiTests.swift @@ -24,6 +24,16 @@ class NvimMsgPackTests: XCTestCase { try? self.nvim.stop().wait() } + func testSth() { + nvim + .command(command: "pwd") + .subscribe(onCompleted: { print("completed") }, onError: { print($0) }) +// .subscribe(onSuccess: { print($0) }) + .disposed(by: self.disposeBag) + + sleep(1) + } + func testExample() { let formatter = DateFormatter() formatter.dateStyle = .short @@ -33,9 +43,7 @@ class NvimMsgPackTests: XCTestCase { for i in 0...5 { nvim .command( - command: "echo '\(formatter.string(from: now)) \(i)'", - expectsReturnValue: true, - checkBlocked: true + command: "echo '\(formatter.string(from: now)) \(i)'" ) .subscribe(onCompleted: { print("\(i) handled") }) .disposed(by: dispose) diff --git a/RxPack/RxPack.xcodeproj/project.pbxproj b/RxPack/RxPack.xcodeproj/project.pbxproj index b0eea7c7..cdce1f10 100644 --- a/RxPack/RxPack.xcodeproj/project.pbxproj +++ b/RxPack/RxPack.xcodeproj/project.pbxproj @@ -12,7 +12,6 @@ 4B022664224AB1490052362B /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B022662224AB1490052362B /* MainMenu.xib */; }; 4B02266F224ACCE70052362B /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B02266D224ACCE10052362B /* RxSwift.framework */; }; 4B022670224ACCE70052362B /* RxSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4B02266D224ACCE10052362B /* RxSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 4B022685224ACFCB0052362B /* ReadersWriterLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B022683224ACFCB0052362B /* ReadersWriterLock.swift */; }; 4B022686224ACFCB0052362B /* RxMessagePort.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B022684224ACFCB0052362B /* RxMessagePort.swift */; }; 4B0226A8224B58DB0052362B /* RxMsgpackRpcTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B0226A7224B58DB0052362B /* RxMsgpackRpcTests.swift */; }; 4B0226AD224B59010052362B /* Socket.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B02268E224B56F10052362B /* Socket.framework */; }; @@ -21,14 +20,12 @@ 4B0226B1224B5A180052362B /* MessagePack.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B02268D224B56F10052362B /* MessagePack.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4B0226B2224B5A180052362B /* Socket.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B02268E224B56F10052362B /* Socket.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4B0226B3224B5A180052362B /* RxSwift.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B02266D224ACCE10052362B /* RxSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 4B0226B4224B5A310052362B /* ReadersWriterLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B022683224ACFCB0052362B /* ReadersWriterLock.swift */; }; 4B0226B5224B5A310052362B /* RxMsgpackRpc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BDD5380FFB00320A20C9 /* RxMsgpackRpc.swift */; }; 4BB1EF8C224B62BB00A5CD5A /* RxSwiftCommons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB1EF8B224B625700A5CD5A /* RxSwiftCommons.swift */; }; 4BB1EF98224B66AB00A5CD5A /* RxNeovimApiTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB1EF97224B66AB00A5CD5A /* RxNeovimApiTests.swift */; }; 4BB1EF9D224B66BB00A5CD5A /* RxNeovimApi.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB1EF90224B662E00A5CD5A /* RxNeovimApi.generated.swift */; }; 4BB1EF9E224B66BB00A5CD5A /* RxNeovimApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB1EF8E224B662E00A5CD5A /* RxNeovimApi.swift */; }; 4BB1EFA0224B66BB00A5CD5A /* RxSwiftCommons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB1EF8B224B625700A5CD5A /* RxSwiftCommons.swift */; }; - 4BB1EFA1224B66BB00A5CD5A /* ReadersWriterLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B022683224ACFCB0052362B /* ReadersWriterLock.swift */; }; 4BB1EFA2224B66BB00A5CD5A /* RxMsgpackRpc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BDD5380FFB00320A20C9 /* RxMsgpackRpc.swift */; }; 4BB1EFA3224B66C700A5CD5A /* MessagePack.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B02268D224B56F10052362B /* MessagePack.framework */; }; 4BB1EFA4224B66C700A5CD5A /* Socket.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B02268E224B56F10052362B /* Socket.framework */; }; @@ -84,7 +81,6 @@ 4B022663224AB1490052362B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 4B022665224AB1490052362B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4B02266D224ACCE10052362B /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxSwift.framework; path = ../Carthage/Build/Mac/RxSwift.framework; sourceTree = ""; }; - 4B022683224ACFCB0052362B /* ReadersWriterLock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReadersWriterLock.swift; sourceTree = ""; }; 4B022684224ACFCB0052362B /* RxMessagePort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxMessagePort.swift; sourceTree = ""; }; 4B02268D224B56F10052362B /* MessagePack.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessagePack.framework; path = ../Carthage/Build/Mac/MessagePack.framework; sourceTree = ""; }; 4B02268E224B56F10052362B /* Socket.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Socket.framework; path = ../Carthage/Build/Mac/Socket.framework; sourceTree = ""; }; @@ -136,7 +132,6 @@ children = ( 4BB1EF8D224B660E00A5CD5A /* RxNeovimApi */, 4BB1EF8B224B625700A5CD5A /* RxSwiftCommons.swift */, - 4B022683224ACFCB0052362B /* ReadersWriterLock.swift */, 4B022684224ACFCB0052362B /* RxMessagePort.swift */, 4B02265D224AB1490052362B /* RxMessagePortDemo */, 4B0226A6224B58DB0052362B /* RxMsgpackRpcTests */, @@ -335,7 +330,6 @@ buildActionMask = 2147483647; files = ( 4B022686224ACFCB0052362B /* RxMessagePort.swift in Sources */, - 4B022685224ACFCB0052362B /* ReadersWriterLock.swift in Sources */, 4B02265F224AB1490052362B /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -345,7 +339,6 @@ buildActionMask = 2147483647; files = ( 4BB1EF8C224B62BB00A5CD5A /* RxSwiftCommons.swift in Sources */, - 4B0226B4224B5A310052362B /* ReadersWriterLock.swift in Sources */, 4B0226B5224B5A310052362B /* RxMsgpackRpc.swift in Sources */, 4B0226A8224B58DB0052362B /* RxMsgpackRpcTests.swift in Sources */, ); @@ -358,7 +351,6 @@ 4BB1EF9D224B66BB00A5CD5A /* RxNeovimApi.generated.swift in Sources */, 4BB1EF9E224B66BB00A5CD5A /* RxNeovimApi.swift in Sources */, 4BB1EFA0224B66BB00A5CD5A /* RxSwiftCommons.swift in Sources */, - 4BB1EFA1224B66BB00A5CD5A /* ReadersWriterLock.swift in Sources */, 4BB1EFA2224B66BB00A5CD5A /* RxMsgpackRpc.swift in Sources */, 4BB1EF98224B66AB00A5CD5A /* RxNeovimApiTests.swift in Sources */, ); diff --git a/RxPack/bin/generate_api_methods.py b/RxPack/bin/generate_api_methods.py index 53d35b97..4137efe9 100755 --- a/RxPack/bin/generate_api_methods.py +++ b/RxPack/bin/generate_api_methods.py @@ -12,15 +12,14 @@ import io void_func_template = Template('''\ func ${func_name}(${args} - expectsReturnValue: Bool = true, - checkBlocked: Bool = true + expectsReturnValue: Bool = false ) -> Completable { let params: [RxNeovimApi.Value] = [ ${params} ] - if expectsReturnValue && checkBlocked { + if expectsReturnValue { return self .checkBlocked( self.rpc(method: "${nvim_func_name}", params: params, expectsReturnValue: expectsReturnValue) @@ -55,7 +54,7 @@ get_mode_func_template = Template('''\ func_template = Template('''\ func ${func_name}(${args} - checkBlocked: Bool = true + errWhenBlocked: Bool = true ) -> Single<${result_type}> { let params: [RxNeovimApi.Value] = [ @@ -70,7 +69,7 @@ func_template = Template('''\ return result } - if checkBlocked { + if errWhenBlocked { return self .checkBlocked( self.rpc(method: "${nvim_func_name}", params: params, expectsReturnValue: true) diff --git a/VimR/VimR.xcodeproj/project.pbxproj b/VimR/VimR.xcodeproj/project.pbxproj index 0b69cb9c..fc715ae8 100644 --- a/VimR/VimR.xcodeproj/project.pbxproj +++ b/VimR/VimR.xcodeproj/project.pbxproj @@ -1920,7 +1920,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 335; + CURRENT_PROJECT_VERSION = 336; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_HARDENED_RUNTIME = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -1981,7 +1981,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 335; + CURRENT_PROJECT_VERSION = 336; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_HARDENED_RUNTIME = YES; ENABLE_NS_ASSERTIONS = NO; diff --git a/VimR/VimR/Info.plist b/VimR/VimR/Info.plist index f772ec46..889898fd 100644 --- a/VimR/VimR/Info.plist +++ b/VimR/VimR/Info.plist @@ -1224,7 +1224,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.30.0 + SNAPSHOT-336 CFBundleSignature ???? CFBundleURLTypes @@ -1241,7 +1241,7 @@ CFBundleVersion - 335 + 336 LSApplicationCategoryType public.app-category.productivity LSMinimumSystemVersion diff --git a/VimR/VimR/OpenQuicklyWindow.swift b/VimR/VimR/OpenQuicklyWindow.swift index 3f750c8a..8b1316b1 100644 --- a/VimR/VimR/OpenQuicklyWindow.swift +++ b/VimR/VimR/OpenQuicklyWindow.swift @@ -152,6 +152,7 @@ class OpenQuicklyWindow: NSObject, private func reset() { self.scanToken = Token() self.currentSearchService?.stopScanScore() + self.currentSearchService = nil self.endProgress() self.unsortedScoredUrls.removeAll() diff --git a/VimR/VimRTests/Info.plist b/VimR/VimRTests/Info.plist index 5f118281..d2dd8f69 100644 --- a/VimR/VimRTests/Info.plist +++ b/VimR/VimRTests/Info.plist @@ -15,10 +15,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 0.30.0 + SNAPSHOT-336 CFBundleSignature ???? CFBundleVersion - 335 + 336 diff --git a/appcast_snapshot.xml b/appcast_snapshot.xml index 844bd732..d93fc185 100644 --- a/appcast_snapshot.xml +++ b/appcast_snapshot.xml @@ -7,37 +7,23 @@ Most recent changes with links to updates for VimR. en - v0.30.0-335 + SNAPSHOT-336 -
  • Improve Open Quickly -
  • -
  • GH-730: Add "Close Window" menu item, which closes all tabs (and the VimR window).
  • -
  • GH-768: Bugfix: coc.nvim does not work.
  • -
  • Bugfix: VimR hangs when there are windows in which nvim is waiting for user input.
  • -
  • Bugfix: Forward search in Markdown preview does not work.
  • -
  • Bugfix: "Open Quickly" result rows are not dark mode compatible.
  • -
  • Bugfix: Enter without selecting a result in the "Open Quickly" window results in a crash.
  • -
  • Dependencies updates:
      -
    • IBM-Swift/BlueSocket 1.0.52
    • -
    • elegantchaos/DictionaryCoding 1.0.7
    • -
    -
  • +
  • Note that SNAPSHOT builds are prone to be very unstable.
  • +
  • Improve handling of file system changes for the file browser
  • ]]>
    - https://github.com/qvacua/vimr/releases/tag/v0.30.0-335 + https://github.com/qvacua/vimr/releases/tag/snapshot/336 - 2020-01-24T23:40:24.018858 + 2020-01-26T22:17:08.186659 10.12.0 -