mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 03:25:03 +03:00
Get the error msg for tabclose
This commit is contained in:
parent
ce4227f796
commit
6c7ff8a300
@ -74,29 +74,6 @@ extension NvimView {
|
||||
|
||||
self.log.info("NVIM_LISTEN_ADDRESS=\(sockPath)")
|
||||
|
||||
self.api.msgpackRawStream
|
||||
.subscribe(onNext: { [weak self] msg in
|
||||
switch msg {
|
||||
|
||||
case let .notification(method, params):
|
||||
self?.log.debug("NOTIFICATION: \(method): \(params)")
|
||||
|
||||
guard method == NvimView.rpcEventName else { return }
|
||||
self?.eventsSubject.onNext(.rpcEvent(params))
|
||||
|
||||
case let .error(_, msg):
|
||||
self?.log.debug("MSG ERROR: \(msg)")
|
||||
|
||||
default:
|
||||
self?.log.debug("???: This should not happen")
|
||||
break
|
||||
|
||||
}
|
||||
}, onError: { [weak self] error in
|
||||
self?.log.error(error)
|
||||
})
|
||||
.disposed(by: self.disposeBag)
|
||||
|
||||
// We wait here, since the user of NvimView cannot subscribe
|
||||
// on the Completable. We could demand that the user call launchNeoVim()
|
||||
// by themselves, but...
|
||||
|
@ -165,10 +165,37 @@ public class NvimView: NSView,
|
||||
super.init(frame: .zero)
|
||||
|
||||
self.api.streamResponses = true
|
||||
self.api.msgpackRawStream.subscribe(onNext: {Swift.print($0)})
|
||||
self.api.msgpackRawStream
|
||||
.subscribe(onNext: { [weak self] msg in
|
||||
switch msg {
|
||||
case let .notification(method, params):
|
||||
self?.log.debug("NOTIFICATION: \(method): \(params)")
|
||||
|
||||
guard method == NvimView.rpcEventName else { return }
|
||||
self?.eventsSubject.onNext(.rpcEvent(params))
|
||||
|
||||
case let .error(_, msg):
|
||||
self?.log.debug("MSG ERROR: \(msg)")
|
||||
|
||||
case let .response(_, error, _):
|
||||
guard let array = error.arrayValue,
|
||||
array.count >= 2,
|
||||
array[0].uint64Value == RxNeovimApi.Error.exceptionRawValue,
|
||||
let errorMsg = array[1].stringValue else { return }
|
||||
|
||||
if errorMsg.contains("Vim(tabclose):E784") { Swift.print("cannot close last tab page!") }
|
||||
if errorMsg.starts(with: "Vim(tabclose):E37") { Swift.print("no write!") }
|
||||
|
||||
default:
|
||||
self?.log.debug("???: This should not happen")
|
||||
}
|
||||
}, onError: {
|
||||
[weak self] error in self?.log.error(error)
|
||||
})
|
||||
.disposed(by: self.disposeBag)
|
||||
|
||||
let db = self.disposeBag
|
||||
self.tabBar?.closeHandler = { [weak self] index, _, entries in
|
||||
self.tabBar?.closeHandler = { [weak self] index, _, _ in
|
||||
self?.api
|
||||
.command(command: "tabclose \(index + 1)")
|
||||
.subscribe()
|
||||
|
@ -9,8 +9,8 @@ extension RxNeovimApi {
|
||||
|
||||
public enum Error: Swift.Error {
|
||||
|
||||
private static let exceptionRawValue = UInt64(0)
|
||||
private static let validationRawValue = UInt64(1)
|
||||
public static let exceptionRawValue = UInt64(0)
|
||||
public static let validationRawValue = UInt64(1)
|
||||
|
||||
case exception(message: String)
|
||||
case validation(message: String)
|
||||
|
@ -33,11 +33,6 @@ public final class RxNeovimApi {
|
||||
set { self.msgpackRpc.streamResponses = newValue }
|
||||
}
|
||||
|
||||
public var streamRawResponses: Bool {
|
||||
get { self.msgpackRpc.streamResponses }
|
||||
set { self.msgpackRpc.streamResponses = newValue }
|
||||
}
|
||||
|
||||
public var msgpackRawStream: Observable<RxMsgpackRpc.Message> { self.msgpackRpc.stream }
|
||||
|
||||
public func run(at path: String) -> Completable { self.msgpackRpc.run(at: path) }
|
||||
|
@ -390,7 +390,7 @@ def parse_version(version):
|
||||
def parse_error_types(error_types):
|
||||
return textwrap.indent(
|
||||
'\n'.join(
|
||||
[f'private static let {t.lower()}RawValue = UInt64({v["id"]})' for t, v in error_types.items()]
|
||||
[f'public static let {t.lower()}RawValue = UInt64({v["id"]})' for t, v in error_types.items()]
|
||||
),
|
||||
' '
|
||||
).lstrip()
|
||||
|
@ -30,10 +30,10 @@ else
|
||||
fi
|
||||
|
||||
if [[ "$download" == true ]]; then
|
||||
curl -L -o ./${BUILD_DIR}/nvim-macos.tar.bz2 "https://github.com/neovim/neovim/releases/download/$target_version/nvim-macos.tar.bz2"
|
||||
curl -L -o ./${BUILD_DIR}/nvim-macos.tar.gz "https://github.com/neovim/neovim/releases/download/$target_version/nvim-macos.tar.gz"
|
||||
echo "Downloaded $target_version"
|
||||
pushd ./${BUILD_DIR}
|
||||
tar xjf nvim-macos.tar.bz2
|
||||
tar xf nvim-macos.tar.gz
|
||||
popd
|
||||
echo "Extracted $target_version"
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user