Revision: 30033
http://sourceforge.net/p/bibdesk/svn/30033
Author: hofman
Date: 2026-02-21 17:57:14 +0000 (Sat, 21 Feb 2026)
Log Message:
-----------
get row for field to select after edit end when a row may be removed rather
than editing the row by index
Modified Paths:
--------------
trunk/bibdesk/BDSKEditor.h
trunk/bibdesk/BDSKEditor.m
Modified: trunk/bibdesk/BDSKEditor.h
===================================================================
--- trunk/bibdesk/BDSKEditor.h 2026-02-21 17:14:58 UTC (rev 30032)
+++ trunk/bibdesk/BDSKEditor.h 2026-02-21 17:57:14 UTC (rev 30033)
@@ -86,6 +86,8 @@
NSMutableSet<NSString *> *addedFields;
+ NSInteger minNumberOfFields;
+
//
----------------------------------------------------------------------------------------
// status bar stuff
//
----------------------------------------------------------------------------------------
Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m 2026-02-21 17:14:58 UTC (rev 30032)
+++ trunk/bibdesk/BDSKEditor.m 2026-02-21 17:57:14 UTC (rev 30033)
@@ -2146,6 +2146,7 @@
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView
doCommandBySelector:(SEL)commandSelector {
NSInteger row = [tableView rowForView:control];
+ BOOL nonRemovable = row < minNumberOfFields;
if (commandSelector == @selector(cancelOperation:)) {
[control abortEditing];
if (row != -1)
@@ -2168,10 +2169,18 @@
} else if (commandSelector != @selector(insertNewline:)) {
return NO;
}
- // ending the edit can remove a row and make the row invalid
- if (editorFlags.isEditing == NO || row + 1 < [tableView numberOfRows] ||
[[[control currentEditor] string] length] > 0 ||
- ([[self window] makeFirstResponder:[self window]] && row < [tableView
numberOfRows]))
+ if (nonRemovable || editorFlags.isEditing == NO || [[[control
currentEditor] string] length] > 0) {
[tableView editColumn:1 row:row withEvent:nil select:YES];
+ } else {
+ // ending the edit may remove the row, which could lead to an invalid
row selection
+ NSString *field = [fields objectAtIndex:row];
+ if ([[self window] makeFirstResponder:[self window]]) {
+ if (row >= [tableView numberOfRows] || [[fields objectAtIndex:row]
isEqualToString:field] == NO)
+ row = [fields indexOfObject:field];
+ if (row < [tableView numberOfRows])
+ [tableView editColumn:1 row:row withEvent:nil select:YES];
+ }
+ }
return YES;
}
@@ -3330,6 +3339,8 @@
}
}
+ minNumberOfFields = [currentFields count];
+
allFields = [[publication allFieldNames] mutableCopy];
[allFields addNonDuplicateObjectsFromArray:[addedFields allObjects]];
[allFields sortUsingSelector:@selector(caseInsensitiveNumericCompare:)];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit