<commit_before>//
//  UpdateSelectionOperation.swift
//  NetNewsWire-iOS
//
//  Created by <NAME> on 2/22/20.
//  Copyright © 2020 Ranchero Software. All rights reserved.
//

import UIKit
import RSCore

class UpdateSelectionOperation: MainThreadOperation {
	
	// MainThreadOperation
	public var isCanceled = false
	public var id: Int?
	public weak var operationDelegate: MainThreadOperationDelegate?
	public var name: String? = "UpdateSelectionOperation"
	public var completionBlock: MainThreadOperation.MainThreadOperationCompletionBlock?

	private var coordinator: SceneCoordinator
	private var dataSource: MasterFeedDataSource
	private var tableView: UITableView
	private var animations: Animations
	
	init(coordinator: SceneCoordinator, dataSource: MasterFeedDataSource, tableView: UITableView, animations: Animations) {
		self.coordinator = coordinator
		self.dataSource = dataSource
		self.tableView = tableView
		self.animations = animations
	}
	
	func run() {
		if dataSource.snapshot().numberOfItems > 0 {
			if let indexPath = coordinator.currentFeedIndexPath {
				CATransaction.begin()
				CATransaction.setCompletionBlock {
					self.operationDelegate?.operationDidComplete(self)
				}
				tableView.selectRowAndScrollIfNotVisible(at: indexPath, animations: animations)
				CATransaction.commit()
			} else {
				tableView.selectRow(at: nil, animated: animations.contains(.select), scrollPosition: .none)
				self.operationDelegate?.operationDidComplete(self)
			}
		} else {
			self.operationDelegate?.operationDidComplete(self)
		}
	}
	
}
<commit_msg>Don't end the operation until the deselection animation has completed.  (Regression)<commit_after>//
//  UpdateSelectionOperation.swift
//  NetNewsWire-iOS
//
//  Created by <NAME> on 2/22/20.
//  Copyright © 2020 Ranchero Software. All rights reserved.
//

import UIKit
import RSCore

class UpdateSelectionOperation: MainThreadOperation {
	
	// MainThreadOperation
	public var isCanceled = false
	public var id: Int?
	public weak var operationDelegate: MainThreadOperationDelegate?
	public var name: String? = "UpdateSelectionOperation"
	public var completionBlock: MainThreadOperation.MainThreadOperationCompletionBlock?

	private var coordinator: SceneCoordinator
	private var dataSource: MasterFeedDataSource
	private var tableView: UITableView
	private var animations: Animations
	
	init(coordinator: SceneCoordinator, dataSource: MasterFeedDataSource, tableView: UITableView, animations: Animations) {
		self.coordinator = coordinator
		self.dataSource = dataSource
		self.tableView = tableView
		self.animations = animations
	}
	
	func run() {
		if dataSource.snapshot().numberOfItems > 0 {
			if let indexPath = coordinator.currentFeedIndexPath {
				CATransaction.begin()
				CATransaction.setCompletionBlock {
					self.operationDelegate?.operationDidComplete(self)
				}
				tableView.selectRowAndScrollIfNotVisible(at: indexPath, animations: animations)
				CATransaction.commit()
			} else {
				if animations.contains(.select) {
					CATransaction.begin()
					CATransaction.setCompletionBlock {
						self.operationDelegate?.operationDidComplete(self)
					}
					tableView.selectRow(at: nil, animated: true, scrollPosition: .none)
					CATransaction.commit()
				} else {
					tableView.selectRow(at: nil, animated: false, scrollPosition: .none)
					self.operationDelegate?.operationDidComplete(self)
				}
			}
		} else {
			self.operationDelegate?.operationDidComplete(self)
		}
	}
	
}

{'fraction_non_alphanumeric': 0.08383751080380294, 'fraction_numerical': 0.005762028233938346, 'mean_word_length': 4.581993569131833, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4764879', 'n_tokens_mistral': 1147, 'n_tokens_neox': 948, 'n_words': 233}