mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-28 02:54:31 +03:00
GH-339 React to cursor moved also
This commit is contained in:
parent
7d69f6f1ae
commit
63b3a35ba9
@ -1288,6 +1288,9 @@ extension NeoVimView {
|
||||
self.grid.goto(position)
|
||||
self.grid.moveCursor(screenCursor)
|
||||
}
|
||||
DispatchUtils.gui {
|
||||
self.delegate?.cursor(to: currentPosition)
|
||||
}
|
||||
}
|
||||
|
||||
public func updateMenu() {
|
||||
|
@ -18,4 +18,5 @@ public protocol NeoVimViewDelegate: class {
|
||||
func ipcBecameInvalid(reason: String)
|
||||
|
||||
func scroll()
|
||||
func cursor(to: Position)
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ class MainWindowComponent: WindowComponent,
|
||||
enum ScrollAction {
|
||||
|
||||
case scroll(to: Position)
|
||||
case cursor(to: Position)
|
||||
}
|
||||
|
||||
fileprivate static let nibName = "MainWindow"
|
||||
@ -560,8 +561,11 @@ extension MainWindowComponent {
|
||||
}
|
||||
|
||||
func scroll() {
|
||||
let pos = self.neoVimView.currentPosition
|
||||
self.scrollFlow.publish(event: ScrollAction.scroll(to: pos))
|
||||
self.scrollFlow.publish(event: ScrollAction.scroll(to: self.neoVimView.currentPosition))
|
||||
}
|
||||
|
||||
func cursor(to position: Position) {
|
||||
self.scrollFlow.publish(event: ScrollAction.cursor(to: self.neoVimView.currentPosition))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,12 +291,12 @@ class MarkdownRenderer: NSObject, Flow, PreviewRenderer {
|
||||
|
||||
fileprivate func scrollSubscription(source: Observable<Any>) -> Disposable {
|
||||
return source
|
||||
.throttle(0.5, latest: true, scheduler: MainScheduler.instance)
|
||||
.throttle(1, latest: true, scheduler: MainScheduler.instance)
|
||||
.filter { $0 is MainWindowComponent.ScrollAction }
|
||||
.map { $0 as! MainWindowComponent.ScrollAction }
|
||||
.subscribe(onNext: { [unowned self] action in
|
||||
switch action {
|
||||
case let .scroll(to: position):
|
||||
case let .scroll(to: position), let .cursor(to: position):
|
||||
self.currentEditorPosition = position
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ class MarkdownRenderer: NSObject, Flow, PreviewRenderer {
|
||||
|
||||
fileprivate func addReactions() {
|
||||
self.webviewMessageHandler.flow.sink
|
||||
.throttle(0.5, latest: true, scheduler: MainScheduler.instance)
|
||||
.throttle(1, latest: true, scheduler: MainScheduler.instance)
|
||||
.filter { $0 is WebviewMessageHandler.Action }
|
||||
.map { $0 as! WebviewMessageHandler.Action }
|
||||
.subscribe(onNext: { [weak self] action in
|
||||
|
Loading…
Reference in New Issue
Block a user