aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
authorjakob <jakob@eggerapps.at>2010-04-16 17:59:50 +0000
committerjakob <jakob@eggerapps.at>2010-04-16 17:59:50 +0000
commitba21a4f70e5326b51eaf1ff9d3dc788e77350c25 (patch)
tree442ec3b686ec65c68f1f186fe25865c8421b7781 /Source/TableContent.m
parentf5f15a660b5663865347e2b2b162fba7ad86566f (diff)
downloadsequelpro-ba21a4f70e5326b51eaf1ff9d3dc788e77350c25.tar.gz
sequelpro-ba21a4f70e5326b51eaf1ff9d3dc788e77350c25.tar.bz2
sequelpro-ba21a4f70e5326b51eaf1ff9d3dc788e77350c25.zip
Improved index checking when using arrow key navigation. Potential fix for http://spbugs.com/l/120
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m20
1 files changed, 14 insertions, 6 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 07a69ad8..cfad7136 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -3185,14 +3185,17 @@
// Trap down arrow key
else if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(moveDown:)] )
{
- if (row==tableRowsCount) return TRUE; //check if we're already at the end of the list
+ NSUInteger newRow = row+1;
+ if (newRow>=tableRowsCount) return TRUE; //check if we're already at the end of the list
[[control window] makeFirstResponder:control];
[self addRowToDB];
- if (row==tableRowsCount) return TRUE; //check again. addRowToDB could reload the table and change the number of rows
- [tableContentView selectRow:row+1 byExtendingSelection:NO];
- [tableContentView editColumn:column row:row+1 withEvent:nil select:YES];
+ if (newRow>=tableRowsCount) return TRUE; //check again. addRowToDB could reload the table and change the number of rows
+ if (column>=[tableValues columnCount]) return TRUE; //the column count could change too
+
+ [tableContentView selectRowIndexes:[NSIndexSet indexSetWithIndex:newRow] byExtendingSelection:NO];
+ [tableContentView editColumn:column row:newRow withEvent:nil select:YES];
return TRUE;
}
@@ -3200,11 +3203,16 @@
else if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(moveUp:)] )
{
if (row==0) return TRUE; //already at the beginning of the list
+ NSUInteger newRow = row-1;
[[control window] makeFirstResponder:control];
[self addRowToDB];
- [tableContentView selectRow:row-1 byExtendingSelection:NO];
- [tableContentView editColumn:column row:row-1 withEvent:nil select:YES];
+
+ if (newRow>=tableRowsCount) return TRUE; // addRowToDB could reload the table and change the number of rows
+ if (column>=[tableValues columnCount]) return TRUE; //the column count could change too
+
+ [tableContentView selectRowIndexes:[NSIndexSet indexSetWithIndex:newRow] byExtendingSelection:NO];
+ [tableContentView editColumn:column row:newRow withEvent:nil select:YES];
return TRUE;
}