Skip to content

Commit

Permalink
Merge branch 'release/3.1.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Feb 22, 2017
2 parents 81ff199 + 3d8ffca commit c7d95a4
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 33 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ develop



3.1.5
--------------------------

### Fixes

- Fix an issue where the application could crash by auto-completion on OS X 10.10.



3.1.4 (182)
--------------------------

Expand Down
4 changes: 2 additions & 2 deletions CotEditor/CotEditor -AppStore-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.1.4</string>
<string>3.1.5</string>
<key>CFBundleSignature</key>
<string>cEd1</string>
<key>CFBundleVersion</key>
<string>182</string>
<string>184</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions CotEditor/CotEditor-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.1.4</string>
<string>3.1.5</string>
<key>CFBundleSignature</key>
<string>cEd1</string>
<key>CFBundleVersion</key>
<string>182</string>
<string>184</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,27 @@
<h1>Release Notes</h1>


<!-- <li>Now, AppleScript's script bundles can specify execution mode to enable running the script inside the application Sandbox (thanks to Kaito Udagawa!).
<ul>
<li>See <a href="about_script_hook.html">Adding scripting hooks for CotEditor scripts</a> from the Help menu &gt; CotEditor Scripting Manual &gt; <a href="about_scripting.html">About Scripting</a> for details.</li>
</ul></li> -->
<article>
<header>
<h1>CotEditor 3.1.5</h1>
<p>release: <time>2016-02</time></p>
</header>


<section>
<h3>Fixes</h3>

<ul>
<li>Fix an issue where the application could crash by auto-completion on OS X 10.10.</li>
</ul>
</section>
</article>


<article>
<header>
<h1>CotEditor 3.1.4</h1>
<p>release: <time>2016-02</time></p>
<p>release: <time>2016-02-20</time></p>
</header>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,28 @@ <h1>リリースノート</h1>

<article>
<header>
<h1>CotEditor 3.1.4</h1>
<h1>CotEditor 3.1.5</h1>
<p>リリース: <time>2016-02</time></p>
</header>


<section>
<h2>修正</h2>

<ul>
<li>OS X 10.10 で自動補完をするとアプリケーションアイコンがクラッシュすることがある不具合を修正</li>
</ul>
</section>
</article>


<article>
<header>
<h1>CotEditor 3.1.4</h1>
<p>リリース: <time>2016-02-20</time></p>
</header>


<section>
<h2>新機能</h2>

Expand Down
4 changes: 3 additions & 1 deletion CotEditor/Sources/EditorTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ final class EditorTextView: NSTextView, Themable {
var initialMagnificationScale: CGFloat = 0
var deferredMagnification: CGFloat = 0

private(set) lazy var completionTask: Debouncer = Debouncer { [weak self] in self?.performCompletion() }
private(set) lazy var completionTask: Debouncer = Debouncer { [weak container = self.textContainer] in // NSTextView cannot be weak
(container?.textView as? EditorTextView)?.performCompletion()
}


// MARK: Private Properties
Expand Down
28 changes: 17 additions & 11 deletions CotEditor/Sources/SyntaxManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ final class SyntaxManager: SettingFileManager {

// load from file
if let url = self.urlForUsedSetting(name: name),
let style = self.styleDictionary(fileURL: url) {
let style = try? self.styleDictionary(fileURL: url) {

// store newly loaded style
self.styleCaches[name] = style
Expand All @@ -273,7 +273,7 @@ final class SyntaxManager: SettingFileManager {

guard let url = self.urlForBundledSetting(name: name) else { return nil }

return self.styleDictionary(fileURL: url)
return try? self.styleDictionary(fileURL: url)
}


Expand Down Expand Up @@ -412,15 +412,21 @@ final class SyntaxManager: SettingFileManager {

// MARK: Private Methods

/// return style dictionary at file URL
private func styleDictionary(fileURL: URL) -> StyleDictionary? {
/// Return style dictionary at file URL.
///
/// - parameter fileURL: URL to a style file.
/// - throws: CocoaError
private func styleDictionary(fileURL: URL) throws -> StyleDictionary {

guard
let yamlData = try? Data(contentsOf: fileURL),
let yaml = try? YAMLSerialization.object(withYAMLData: yamlData,
options: kYAMLReadOptionMutableContainersAndLeaves) else { return nil }
let yamlData = try Data(contentsOf: fileURL)
let yaml = try YAMLSerialization.object(withYAMLData: yamlData,
options: kYAMLReadOptionMutableContainersAndLeaves)

guard let styleDictionary = yaml as? StyleDictionary else {
throw CocoaError(.fileReadCorruptFile)
}

return yaml as? StyleDictionary
return styleDictionary
}


Expand Down Expand Up @@ -459,14 +465,14 @@ final class SyntaxManager: SettingFileManager {
let directoryURL = self.userSettingDirectoryURL
var map = self.bundledMap

// load user styles
// load user styles if exists
if let enumerator = FileManager.default.enumerator(at: directoryURL, includingPropertiesForKeys: nil,
options: [.skipsSubdirectoryDescendants, .skipsHiddenFiles]) {
for case let url as URL in enumerator {
guard [self.filePathExtension, "yml"].contains(url.pathExtension) else { continue }
guard let style = try? self.styleDictionary(fileURL: url) else { continue }

let styleName = self.settingName(from: url)
guard let style = self.styleDictionary(fileURL: url) else { continue }

map[styleName] = [SyntaxKey.extensions.rawValue: type(of: self).keyStrings(in: style, key: .extensions),
SyntaxKey.filenames.rawValue: type(of: self).keyStrings(in: style, key: .filenames),
Expand Down
32 changes: 21 additions & 11 deletions CotEditor/Sources/ThemeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
------------------------------------------------------------------------------
© 2014-2016 1024jp
© 2014-2017 1024jp
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -246,12 +246,20 @@ final class ThemeManager: SettingFileManager {

// MARK: Private Methods

/// create ThemeDictionary from a file at the URL
private func themeDictionary(fileURL: URL) -> ThemeDictionary? {
/// Create ThemeDictionary from a file at the URL.
///
/// - parameter fileURL: URL to a theme file.
/// - throws: CocoaError
private func themeDictionary(fileURL: URL) throws -> ThemeDictionary {

guard let data = try? Data(contentsOf: fileURL) else { return nil }
let data = try Data(contentsOf: fileURL)
let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers)

return (try? JSONSerialization.jsonObject(with: data, options: .mutableContainers)) as? ThemeDictionary
guard let themeDictionry = json as? ThemeDictionary else {
throw CocoaError(.fileReadCorruptFile)
}

return themeDictionry
}


Expand All @@ -265,9 +273,8 @@ final class ThemeManager: SettingFileManager {
let themeNameSet = NSMutableOrderedSet(array: strongSelf.bundledThemeNames)

// load user themes if exists
if userDirURL.isReachable {
let fileURLs = (try? FileManager.default.contentsOfDirectory(at: userDirURL, includingPropertiesForKeys: nil,
options: [.skipsSubdirectoryDescendants, .skipsHiddenFiles])) ?? []
if let fileURLs = try? FileManager.default.contentsOfDirectory(at: userDirURL, includingPropertiesForKeys: nil,
options: [.skipsSubdirectoryDescendants, .skipsHiddenFiles]) {
let userThemeNames = fileURLs
.filter { $0.pathExtension == strongSelf.filePathExtension }
.map { strongSelf.settingName(from: $0) }
Expand All @@ -280,10 +287,13 @@ final class ThemeManager: SettingFileManager {

// cache definitions
strongSelf.archivedThemes = (themeNameSet.array as! [String]).reduce([:]) { (dict, name) in
guard let themeURL = strongSelf.urlForUsedSetting(name: name) else { return dict }
guard
let themeURL = strongSelf.urlForUsedSetting(name: name),
let themeDictionary = try? strongSelf.themeDictionary(fileURL: themeURL)
else { return dict }

var dict = dict
dict[name] = strongSelf.themeDictionary(fileURL: themeURL)
dict[name] = themeDictionary
return dict
}

Expand All @@ -310,7 +320,7 @@ final class ThemeManager: SettingFileManager {

let url = self.urlForBundledSetting(name: "_Plain")!

return self.themeDictionary(fileURL: url)!
return try! self.themeDictionary(fileURL: url)
}

}

0 comments on commit c7d95a4

Please sign in to comment.