From 3aa2337971f961f01ba43744fc21466ecc3a53ef Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Sat, 24 Jun 2017 14:12:11 +0200 Subject: [PATCH] GH-472 Fix the row/col mixup --- NeoVimServer/server_ui.m | 12 ++++++------ SwiftNeoVim/NeoVimView+Mouse.swift | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/NeoVimServer/server_ui.m b/NeoVimServer/server_ui.m index 06a7f5ff..287b68c0 100644 --- a/NeoVimServer/server_ui.m +++ b/NeoVimServer/server_ui.m @@ -674,10 +674,10 @@ static NeoVimBuffer *buffer_for(buf_T *buf) { void neovim_scroll(void **argv) { work_and_write_data_sync(argv, ^NSData *(NSData *data) { NSInteger *values = (NSInteger *) data.bytes; - NSInteger horiz = values[0]; - NSInteger vert = values[1]; - NSInteger row = values[2]; - NSInteger column = values[3]; + int horiz = (int) values[0]; + int vert = (int) values[1]; + int row = (int) values[2]; + int column = (int) values[3]; if (horiz == 0 && vert == 0) { return nil; @@ -693,11 +693,11 @@ void neovim_scroll(void **argv) { int vertDir; if (horiz != 0) { horizDir = horiz > 0 ? MSCR_RIGHT: MSCR_LEFT; - custom_ui_scroll(horizDir, (int) ABS(horiz), row, column); + custom_ui_scroll(horizDir, ABS(horiz), row, column); } if (vert != 0) { vertDir = vert > 0 ? MSCR_DOWN: MSCR_UP; - custom_ui_scroll(vertDir, (int) ABS(vert), row, column); + custom_ui_scroll(vertDir, ABS(vert), row, column); } refresh_ui_screen(VALID); diff --git a/SwiftNeoVim/NeoVimView+Mouse.swift b/SwiftNeoVim/NeoVimView+Mouse.swift index c643a70a..a05bf54d 100644 --- a/SwiftNeoVim/NeoVimView+Mouse.swift +++ b/SwiftNeoVim/NeoVimView+Mouse.swift @@ -72,11 +72,11 @@ extension NeoVimView { fileprivate func cellPositionFor(event: NSEvent) -> Position { let location = self.convert(event.locationInWindow, from: nil) - let row = Int((location.x - self.xOffset) / self.cellSize.width) - let column = Int((self.bounds.size.height - location.y - self.yOffset) / self.cellSize.height) + let row = Int((self.bounds.size.height - location.y - self.yOffset) / self.cellSize.height) + let column = Int((location.x - self.xOffset) / self.cellSize.width) - let cellPosition = Position(row: min(max(0, row), self.grid.size.width - 1), - column: min(max(0, column), self.grid.size.height - 1)) + let cellPosition = Position(row: min(max(0, row), self.grid.size.height - 1), + column: min(max(0, column), self.grid.size.width - 1)) return cellPosition } @@ -86,7 +86,7 @@ extension NeoVimView { return } - let vimMouseLocation = self.wrapNamedKeys("\(cellPosition.row),\(cellPosition.column)") + let vimMouseLocation = self.wrapNamedKeys("\(cellPosition.column),\(cellPosition.row)") let vimClickCount = self.vimClickCountFrom(event: event) let result: String