1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 03:25:03 +03:00

GH-472 Fix the row/col mixup

This commit is contained in:
Tae Won Ha 2017-06-24 14:12:11 +02:00
parent cb72766cd7
commit 3aa2337971
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 11 additions and 11 deletions

View File

@ -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);

View File

@ -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