Merge tag '3.4.3' into develop

3.4.3

# Conflicts:
#	CHANGELOG.md
#	CotEditor/Info-AppStore.plist
#	CotEditor/Info.plist
#	CotEditor/Sources/SyntaxHighlightParseOperation.swift
This commit is contained in:
1024jp 2018-06-26 09:44:26 +09:00
commit cc8f10f56f
8 changed files with 90 additions and 32 deletions

View File

@ -27,11 +27,17 @@ Change Log
- [non-AppStore ver.] Update Sparkle framework.
3.4.3 (259)
--------------------------
### Fixes
- Fix an issue where the help button in the multiple replace window did not link to the suitable help page.
- Fix an issue where "Show Mapping Conflict" menu item was always available even no conflict exists.
- Fix an issue where the current line highlight was opaque in split editors although the editor background is non-opaque.
- Fix an issue where unwanted debug log was printed in the Console.
- Fix an issue where “Show File Mapping Conflicts” menu item was always available even no conflict exists.
- Improve general stability.
- Fix an unlocalized label.

View File

@ -21,6 +21,28 @@
<h1>Release Notes</h1>
<article>
<header>
<h1>CotEditor 3.4.3</h1>
<p>release: <time>2018-06-26</time></p>
</header>
<section>
<h2>Fixes</h2>
<ul>
<li>Fix an issue where the help button in the multiple replace window did not link to the suitable help page.</li>
<li>Fix an issue where the current line highlight was opaque in split editors although the editor background is non-opaque.</li>
<li>Fix an issue where unwanted debug log was printed in the Console.</li>
<li>Fix an issue where “Show File Mapping Conflicts” menu item was always available even no conflict exists.</li>
<li>Improve general stability.</li>
<li>Fix an unlocalized label.</li>
</ul>
</section>
</article>
<article>
<header>
<h1>CotEditor 3.4.2</h1>

View File

@ -21,6 +21,28 @@
<h1>リリースノート</h1>
<article>
<header>
<h1>CotEditor 3.4.3</h1>
<p>リリース: <time>2018-06-26</time></p>
</header>
<section>
<h2>修正</h2>
<ul>
<li>複数置換ウインドウのヘルプボタンが正しく機能していなかった不具合を修正</li>
<li>分割エディタでエディタ背景が半透明でも現在行ハイライトが半透明にならなかった不具合を修正</li>
<li>コンソールにデバッグ用ログが出力されていた不具合を修正</li>
<li>“ファイル関連付けのコンフリクトを表示”メニュー項目がコンフリクトがないときにも実行可能だった不具合を修正</li>
<li>全般的な安定性を向上</li>
<li>ローカライズされていなかったメニュー項目を修正</li>
</ul>
</section>
</article>
<article>
<header>
<h1>CotEditor 3.4.2</h1>

View File

@ -1205,6 +1205,10 @@ final class EditorTextView: NSTextView, Themable {
(self.layoutManager as? LayoutManager)?.invisiblesColor = theme.invisibles.color
if !self.isOpaque {
self.lineHighLightColor = self.lineHighLightColor?.withAlphaComponent(0.7)
}
// set scroller color considering background color
self.enclosingScrollView?.scrollerKnobStyle = theme.isDarkTheme ? .light : .default

View File

@ -55,37 +55,43 @@ private struct QuoteCommentItem {
final class SyntaxHighlightParseOperation: AsynchronousOperation, ProgressReporting {
struct ParseDefinition {
var extractors: [SyntaxType: [HighlightExtractable]]
var pairedQuoteTypes: [String: SyntaxType] // dict for quote pair to extract with comment
var inlineCommentDelimiter: String?
var blockCommentDelimiters: Pair<String>?
}
// MARK: Public Properties
var string: String?
var parseRange: NSRange = .notFound
let string: String
let progress: Progress // can be updated from a background thread
var highlightBlock: (([SyntaxType: [NSRange]]) -> Void)?
// MARK: Private Properties
private let extractors: [SyntaxType: [HighlightExtractable]]
private let pairedQuoteTypes: [String: SyntaxType] // dict for quote pair to extract with comment
private let inlineCommentDelimiter: String?
private let blockCommentDelimiters: Pair<String>?
private let definition: ParseDefinition
private let parseRange: NSRange
private let highlightBlock: ([SyntaxType: [NSRange]]) -> Void
// MARK: -
// MARK: Lifecycle
required init(extractors: [SyntaxType: [HighlightExtractable]], pairedQuoteTypes: [String: SyntaxType], inlineCommentDelimiter: String?, blockCommentDelimiters: Pair<String>?) {
required init(definition: ParseDefinition, string: String, range parseRange: NSRange, highlightBlock: @escaping ([SyntaxType: [NSRange]]) -> Void = { _ in }) {
self.extractors = extractors
self.pairedQuoteTypes = pairedQuoteTypes
self.inlineCommentDelimiter = inlineCommentDelimiter
self.blockCommentDelimiters = blockCommentDelimiters
self.definition = definition
self.string = string
self.parseRange = parseRange
self.highlightBlock = highlightBlock
// +1 for extractCommentsWithQuotes()
// +1 for highlighting
self.progress = Progress(totalUnitCount: Int64(extractors.count + 2))
self.progress = Progress(totalUnitCount: Int64(definition.extractors.count + 2))
super.init()
@ -103,7 +109,7 @@ final class SyntaxHighlightParseOperation: AsynchronousOperation, ProgressReport
/// is ready to run
override var isReady: Bool {
return self.string != nil && self.parseRange.location != NSNotFound
return true
}
@ -120,7 +126,7 @@ final class SyntaxHighlightParseOperation: AsynchronousOperation, ProgressReport
self.progress.localizedDescription = NSLocalizedString("Applying colors to text", comment: "")
self.highlightBlock?(results)
self.highlightBlock(results)
self.progress.completedUnitCount += 1
}
@ -137,7 +143,7 @@ final class SyntaxHighlightParseOperation: AsynchronousOperation, ProgressReport
// extract standard highlight ranges
let rangesQueue = DispatchQueue(label: "com.coteditor.CotEdiotor.syntax.ranges", attributes: .concurrent)
for syntaxType in SyntaxType.allCases {
guard let extractors = self.extractors[syntaxType] else { continue }
guard let extractors = self.definition.extractors[syntaxType] else { continue }
self.progress.localizedDescription = String(format: NSLocalizedString("Extracting %@…", comment: ""), syntaxType.localizedName)
@ -148,7 +154,7 @@ final class SyntaxHighlightParseOperation: AsynchronousOperation, ProgressReport
DispatchQueue.concurrentPerform(iterations: extractors.count) { (index: Int) in
guard !self.isCancelled else { return }
let extractedRanges = extractors[index].ranges(in: self.string!, range: self.parseRange)
let extractedRanges = extractors[index].ranges(in: self.string, range: self.parseRange)
rangesQueue.async(flags: .barrier) {
childProgress.completedUnitCount += 1
@ -181,17 +187,17 @@ final class SyntaxHighlightParseOperation: AsynchronousOperation, ProgressReport
/// extract ranges of quoted texts as well as comments in the parse range
private func extractCommentsWithQuotes() -> [SyntaxType: [NSRange]] {
let string = self.string! as NSString
let string = self.string as NSString
var positions = [QuoteCommentItem]()
if let delimiters = self.blockCommentDelimiters {
if let delimiters = self.definition.blockCommentDelimiters {
positions += string.ranges(of: delimiters.begin, range: self.parseRange)
.map { QuoteCommentItem(type: .comments, token: QuoteCommentItem.Token.blockComment, role: .begin, range: $0) }
positions += string.ranges(of: delimiters.end, range: self.parseRange)
.map { QuoteCommentItem(type: .comments, token: QuoteCommentItem.Token.blockComment, role: .end, range: $0) }
}
if let delimiter = self.inlineCommentDelimiter {
if let delimiter = self.definition.inlineCommentDelimiter {
positions += string.ranges(of: delimiter, range: self.parseRange)
.flatMap { range -> [QuoteCommentItem] in
let lineRange = string.lineRange(for: range)
@ -202,13 +208,13 @@ final class SyntaxHighlightParseOperation: AsynchronousOperation, ProgressReport
}
}
for (quote, type) in self.pairedQuoteTypes {
for (quote, type) in self.definition.pairedQuoteTypes {
positions += string.ranges(of: quote, range: self.parseRange)
.map { QuoteCommentItem(type: type, token: quote, role: [.begin, .end], range: $0) }
}
// filter escaped ones
positions = positions.filter { !self.string!.isCharacterEscaped(at: $0.range.location) }
positions = positions.filter { !self.string.isCharacterEscaped(at: $0.range.location) }
// sort by location
positions.sort {

View File

@ -267,14 +267,12 @@ extension SyntaxParser {
return nil
}
let operation = SyntaxHighlightParseOperation(extractors: self.style.highlightExtractors,
pairedQuoteTypes: self.style.pairedQuoteTypes,
inlineCommentDelimiter: self.style.inlineCommentDelimiter,
blockCommentDelimiters: self.style.blockCommentDelimiters)
operation.string = string
operation.parseRange = highlightRange
let definition = SyntaxHighlightParseOperation.ParseDefinition(extractors: self.style.highlightExtractors,
pairedQuoteTypes: self.style.pairedQuoteTypes,
inlineCommentDelimiter: self.style.inlineCommentDelimiter,
blockCommentDelimiters: self.style.blockCommentDelimiters)
operation.highlightBlock = { [weak self] (highlights) in
let operation = SyntaxHighlightParseOperation(definition: definition, string: string, range: highlightRange, highlightBlock: { [weak self] (highlights) in
guard let strongSelf = self else { return }
// cache result if whole text was parsed
@ -288,7 +286,7 @@ extension SyntaxParser {
strongSelf.apply(highlights: highlights, range: highlightRange)
}
}
})
operation.completionBlock = completionHandler