Revision: 28971
          http://sourceforge.net/p/bibdesk/svn/28971
Author:   hofman
Date:     2024-11-12 10:26:34 +0000 (Tue, 12 Nov 2024)
Log Message:
-----------
shift selection range when removing a character from an invalid cite key, which 
can happen after pasting in a cite key field, because it inserts an extra space

Modified Paths:
--------------
    trunk/bibdesk/BDSKCiteKeyFormatter.m
    trunk/bibdesk/BDSKEditor.m

Modified: trunk/bibdesk/BDSKCiteKeyFormatter.m
===================================================================
--- trunk/bibdesk/BDSKCiteKeyFormatter.m        2024-10-24 17:03:27 UTC (rev 
28970)
+++ trunk/bibdesk/BDSKCiteKeyFormatter.m        2024-11-12 10:26:34 UTC (rev 
28971)
@@ -74,6 +74,8 @@
         [new replaceOccurrencesOfCharactersInSet:invalidSet withString:@""];
         if ([new length]) {
             *partialStringPtr = new;
+            if (r.location < proposedSelRangePtr->location)
+                --proposedSelRangePtr->location;
             if (NSMaxRange(*proposedSelRangePtr) > [new length])
                 *proposedSelRangePtr = NSMakeRange(r.location, 0);
         } else {

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2024-10-24 17:03:27 UTC (rev 28970)
+++ trunk/bibdesk/BDSKEditor.m  2024-11-12 10:26:34 UTC (rev 28971)
@@ -1886,7 +1886,9 @@
                 return NO;
             }
         }
-       }
+    } else {
+        [(NSTextView *)fieldEditor setSmartInsertDeleteEnabled:NO];
+    }
     return YES;
 }
 
@@ -1894,6 +1896,11 @@
     [self setEditing:YES];
 }
 
+- (void)controlTextDidChange:(NSNotification *)note {
+    NSTextView *tv = [[note userInfo] objectForKey:@"NSFieldEditor"];
+    NSLog(@"%i", [tv smartInsertDeleteEnabled]);
+}
+
 // send by the formatter when validation failed
 - (void)control:(NSControl *)control didFailToValidatePartialString:(NSString 
*)string errorDescription:(NSString *)error{
     // Don't show an annoying warning. This fails only when invalid cite key 
characters are used, which are simply removed by the formatter.

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to