Revision: 28332
          http://sourceforge.net/p/bibdesk/svn/28332
Author:   hofman
Date:     2023-07-20 14:47:29 +0000 (Thu, 20 Jul 2023)
Log Message:
-----------
add number to temporary displayname when document with the displayname already 
exists

Modified Paths:
--------------
    trunk/bibdesk/BDSKDocumentController.m

Modified: trunk/bibdesk/BDSKDocumentController.m
===================================================================
--- trunk/bibdesk/BDSKDocumentController.m      2023-07-20 09:18:19 UTC (rev 
28331)
+++ trunk/bibdesk/BDSKDocumentController.m      2023-07-20 14:47:29 UTC (rev 
28332)
@@ -351,7 +351,12 @@
             
             if ([filteredString writeToURL:tmpFileURL atomically:YES 
encoding:encoding error:outError]) {
                 if ((doc = [self makeDocumentForURL:nil 
withContentsOfURL:tmpFileURL ofType:BDSKBibTeXDocumentType error:outError])) {
-                    [doc setDisplayName:[tmpFileName 
stringByDeletingPathExtension]];
+                    NSArray *displayNames = [[self documents] 
valueForKey:@"displayName"];
+                    NSString *displayName = [tmpFileName 
stringByDeletingPathExtension];
+                    NSInteger i = 1;
+                    while ([displayNames containsObject:displayName])
+                        displayName = [NSString stringWithFormat:@"%@ %ld", 
[tmpFileName stringByDeletingPathExtension], ++i];
+                    [doc setDisplayName:displayName];
                     [(BibDocument *)doc markAsImported];
                 }
                 [[NSFileManager defaultManager] removeItemAtPath:[tmpFileURL 
path] error:NULL];

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

Reply via email to