Skip to content

Commit

Permalink
Homogenize indentation in moveFolders method
Browse files Browse the repository at this point in the history
Remove extraneous spaces while keeping the tab based spacing
in order to preserve the legibility of git history.
Other slight changes to improve legibility.
  • Loading branch information
barijaona committed Aug 6, 2024
1 parent 68a92d8 commit ce40e27
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions Vienna/Sources/Main window/FoldersTree.m
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ -(BOOL)moveFolders:(NSArray *)array withGoogleSync:(BOOL)sync
NSInteger newPredecessorId = [array[index++] integerValue];
Folder * folder = [dbManager folderFromID:folderId];
NSInteger oldParentId = folder.parentId;

TreeNode * node = [self.rootNode nodeFromID:folderId];
TreeNode * oldParent = [self.rootNode nodeFromID:oldParentId];
NSInteger oldChildIndex = [oldParent indexOfChild:node];
Expand All @@ -926,21 +926,21 @@ -(BOOL)moveFolders:(NSArray *)array withGoogleSync:(BOOL)sync
newPredecessorId = 0;
}
NSInteger newChildIndex = (newPredecessorId > 0) ? ([newParent indexOfChild:newPredecessor] + 1) : 0;

if (newParentId == oldParentId) {
// With automatic sorting, moving under the same parent is impossible.
if (autoSort) {
if (autoSort) {
continue;
}
}
// No need to move if destination is the same as origin.
if (newPredecessorId == oldPredecessorId) {
if (newPredecessorId == oldPredecessorId) {
continue;
}
}
// Adjust the index for the removal of the old child.
if (newChildIndex > oldChildIndex) {
--newChildIndex;
}
if (newChildIndex > oldChildIndex) {
--newChildIndex;
}

} else {
if ([dbManager setParent:newParentId forFolder:folderId]) {
if (sync && folder.type == VNAFolderTypeOpenReader) {
Expand All @@ -951,7 +951,7 @@ -(BOOL)moveFolders:(NSArray *)array withGoogleSync:(BOOL)sync
// add new label
folderName = [dbManager folderFromID:newParentId].name;
if (folderName) {
[myReader setFolderLabel:folderName forFeed:folder.remoteId set:TRUE];
[myReader setFolderLabel:folderName forFeed:folder.remoteId set:TRUE];
}
}
} else {
Expand All @@ -961,7 +961,7 @@ -(BOOL)moveFolders:(NSArray *)array withGoogleSync:(BOOL)sync
[newParent setCanHaveChildren:YES];
}
}

if (!autoSort) {
if (oldPredecessorId > 0) {
if (![dbManager setNextSibling:folder.nextSiblingId forFolder:oldPredecessorId]) {
Expand All @@ -974,12 +974,13 @@ -(BOOL)moveFolders:(NSArray *)array withGoogleSync:(BOOL)sync
}
if (newPredecessorId > 0) {
if (![dbManager setNextSibling:[dbManager folderFromID:newPredecessorId].nextSiblingId
forFolder:folderId]) {
forFolder:folderId]) {
continue;
}
}
[dbManager setNextSibling:folderId forFolder:newPredecessorId];
} else {
NSInteger oldFirstChildId = (newParent == self.rootNode) ? dbManager.firstFolderId : newParent.folder.firstChildId;
NSInteger oldFirstChildId = (newParent == self.rootNode) ? dbManager.firstFolderId
: newParent.folder.firstChildId;
if (![dbManager setNextSibling:oldFirstChildId forFolder:folderId]) {
continue;
}
Expand All @@ -995,17 +996,17 @@ -(BOOL)moveFolders:(NSArray *)array withGoogleSync:(BOOL)sync
[undoArray insertObject:@(oldParentId) atIndex:1u];
[undoArray insertObject:@(oldPredecessorId) atIndex:2u];
}

// If undo array is empty, then nothing has been moved.
if (undoArray.count == 0u) {
return NO;
}

// Set up to undo this action
NSUndoManager * undoManager = NSApp.mainWindow.undoManager;
[undoManager registerUndoWithTarget:self selector:@selector(moveFoldersUndo:) object:undoArray];
[undoManager setActionName:NSLocalizedString(@"Move Folders", nil)];

// Make the outline control reload its data
[self.outlineView reloadData];

Expand All @@ -1019,7 +1020,7 @@ -(BOOL)moveFolders:(NSArray *)array withGoogleSync:(BOOL)sync
}
}
}

// Properly set selection back to the original items. This has to be done after the
// refresh so that rowForItem returns the new positions.
NSMutableIndexSet * selIndexSet = [[NSMutableIndexSet alloc] init];
Expand All @@ -1033,7 +1034,7 @@ -(BOOL)moveFolders:(NSArray *)array withGoogleSync:(BOOL)sync
[self.outlineView scrollRowToVisible:selRowIndex];
[self.outlineView selectRowIndexes:selIndexSet byExtendingSelection:NO];
return YES;
}
} // moveFolders

/* setSearch
* Set string to filter nodes by name, description, url
Expand Down

0 comments on commit ce40e27

Please sign in to comment.