keep entry of send cmd manager selected
This commit is contained in:
@@ -69,18 +69,15 @@ import UIKit
|
||||
print("Failed to create regex")
|
||||
return nil
|
||||
}
|
||||
|
||||
let range = NSRange(location: 0, length: input.utf16.count)
|
||||
guard let match = regex.firstMatch(in: input, options: [], range: range) else {
|
||||
print("No match found for input: \(input)")
|
||||
return nil
|
||||
}
|
||||
|
||||
print("Regex matched for input: \(input)")
|
||||
|
||||
let matchedString = (input as NSString).substring(with: match.range(at: 0))
|
||||
let keyStrings = matchedString.split(separator: "+").map { String($0) }
|
||||
|
||||
guard !keyStrings.isEmpty else {
|
||||
print("No key strings found in the matched string")
|
||||
return nil
|
||||
|
||||
@@ -193,13 +193,14 @@ import UIKit
|
||||
|
||||
@objc public func reloadTableView() {
|
||||
let previouslySelectedIndexPath = tableView.indexPathForSelectedRow
|
||||
|
||||
tableView.layoutIfNeeded()
|
||||
tableView.reloadData()
|
||||
|
||||
|
||||
if let indexPath = previouslySelectedIndexPath {
|
||||
// Make sure the indexPath is still valid and scroll to the selected indexPath
|
||||
if indexPath.row < tableView.numberOfRows(inSection: indexPath.section) {
|
||||
tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
|
||||
print("scrollToRow")
|
||||
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .middle) // keep the entry of previous index selected.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user