1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 00:34:26 +03:00

Migrate OpenQuicklyWindow.State

This commit is contained in:
Tae Won Ha 2018-07-15 10:32:27 +02:00
parent e3958b4802
commit 61132519e5
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -79,21 +79,40 @@ struct AppState: SerializableState {
extension OpenQuicklyWindow {
struct State: SerializableState {
struct State: Codable, SerializableState {
static let `default` = State()
static let defaultIgnorePatterns = Set(["*/.git", "*.o", "*.d", "*.dia"].map(FileItemIgnorePattern.init))
enum CodingKeys: String, CodingKey {
case ignorePatterns
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
if let patternsAsString = try container.decodeIfPresent(String.self, forKey: .ignorePatterns) {
self.ignorePatterns = FileItemIgnorePattern.from(string: patternsAsString)
} else {
self.ignorePatterns = State.defaultIgnorePatterns
}
}
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(FileItemIgnorePattern.toString(self.ignorePatterns), forKey: .ignorePatterns)
}
let root = FileItem(URL(fileURLWithPath: "/", isDirectory: true))
var flatFileItems = Observable<[FileItem]>.empty()
var cwd = FileUtils.userHomeUrl
var ignorePatterns = Set(["*/.git", "*.o", "*.d", "*.dia"].map(FileItemIgnorePattern.init))
var ignorePatterns = State.defaultIgnorePatterns
var ignoreToken = Token()
var open = false
init() {
}
init?(dict: [String: Any]) {