Skip to content

Commit 36285ce

Browse files
committed
Fix mouse picking
Currently, just treat mouse on the gap space to be on the row below it, which is part of the cmdline. The alternative is to treat it as nothing, but that leads to weird situations with the mouse cursor not being reset. Just treat the row below it to have an extra tall hitbox.
1 parent 238ad6b commit 36285ce

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/MacVim/MMCoreTextView.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,15 +1115,35 @@ - (IBAction)selectAll:(id)sender
11151115
[[self windowController] vimMenuItemAction:sender];
11161116
}
11171117

1118+
/// Converts a point in this NSView to a specific Vim row/column.
1119+
///
1120+
/// @param point The point in NSView. Note that it's y-up as that's Mac convention, whereas row starts from the top.
11181121
- (BOOL)convertPoint:(NSPoint)point toRow:(int *)row column:(int *)column
11191122
{
1123+
// Convert y-up to y-down.
11201124
point.y = [self bounds].size.height - point.y;
11211125

11221126
NSPoint origin = { insetSize.width, insetSize.height };
11231127

11241128
if (!(cellSize.width > 0 && cellSize.height > 0))
11251129
return NO;
11261130

1131+
if (alignCmdLineToBottom) {
1132+
// Account for the gap we added to pin cmdline to the bottom of the window
1133+
const NSRect frame = [self bounds];
1134+
const int insetBottom = [[NSUserDefaults standardUserDefaults] integerForKey:MMTextInsetBottomKey];
1135+
const CGFloat gapHeight = frame.size.height - grid.rows*cellSize.height - insetSize.height - insetBottom;
1136+
const CGFloat cmdlineRowY = insetSize.height + cmdlineRow*cellSize.height + 1;
1137+
if (point.y > cmdlineRowY) {
1138+
point.y -= gapHeight;
1139+
if (point.y <= cmdlineRowY) {
1140+
// This was inside the gap between top and bottom lines. Round it down
1141+
// to the next line.
1142+
point.y = cmdlineRowY + 1;
1143+
}
1144+
}
1145+
}
1146+
11271147
if (row) *row = floor((point.y-origin.y-1) / cellSize.height);
11281148
if (column) *column = floor((point.x-origin.x-1) / cellSize.width);
11291149

0 commit comments

Comments
 (0)