Fix CSVSortPattern with whitespace-only component

This commit is contained in:
1024jp 2024-04-21 18:44:46 +09:00
parent de0a4ebcbd
commit f874041953
5 changed files with 8 additions and 1 deletions

View File

@ -16,6 +16,7 @@
- Fix an issue on CotEditor 4.8.0 that custom syntaxes could be empty when it contains ill-formed definitions.
- Fix an issue on CotEditor 4.8.0 that the editor's kerning did not set to zero despite the font type being monospaced.
- Fix an issue on CotEditor 4.8.0 that some steppers in the Settings window were placed on the opposite side.
- Fix an issue that application crashed when the sort key in the Sort by Pattern contains only whitespace.
- Fix an issue that the current line highlight did not appear when the insertion point was located at the last empty line.
- Fix an issue that the same instance highlight remains under specific conditions.

View File

@ -42,6 +42,7 @@
<li>Fix an issue on CotEditor 4.8.0 that custom syntaxes could be empty when it contains ill-formed definitions.</li>
<li>Fix an issue on CotEditor 4.8.0 that the editor's kerning did not set to zero despite the font type being monospaced.</li>
<li>Fix an issue on CotEditor 4.8.0 that some steppers in the Settings window were placed on the opposite side.</li>
<li>Fix an issue that application crashed when the sort key in the Sort by Pattern contains only whitespace.</li>
<li>Fix an issue that the current line highlight did not appear when the insertion point was located at the last empty line.</li>
<li>Fix an issue that the same instance highlight remains under specific conditions.</li>
</ul>

View File

@ -42,6 +42,7 @@
<li>カスタムシンタックスに行儀の良くない定義が入っているにシンタックス定義が空になることがあったCotEditor 4.8.0の不具合を修正</li>
<li>等幅フォントのときにカーニングがゼロにならなかったCotEditor 4.8.0の不具合を修正</li>
<li>設定ウインドウのステッパーが入力欄の反対側に配置されることがあったCotEditor 4.8.0の不具合を修正</li>
<li>「条件で並び替え」の並び替えキーが空白のみのときにアプリケーションがクラッシュした不具合を修正</li>
<li>カーソルが書類末の空行にあるときに現在行のハイライトが描画されなかった不具合を修正</li>
<li>選択した文字のハイライトが特定の状況下で残っていた不具合を修正</li>
</ul>

View File

@ -166,6 +166,9 @@ struct CSVSortPattern: SortPattern {
let trimmedStart = line.index(start, offsetBy: headTrim)
let trimmedEnd = line.index(end, offsetBy: -endTrim)
// oder can be opposite when component contains only whitespace
guard trimmedStart <= trimmedEnd else { return nil }
return trimmedStart..<trimmedEnd
}

View File

@ -9,7 +9,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2018-2023 1024jp
// © 2018-2024 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -50,6 +50,7 @@ final class LineSortTests: XCTestCase {
XCTAssertEqual(pattern.sort(self.lines), result)
XCTAssertEqual(pattern.sort(""), "")
XCTAssertNoThrow(try pattern.validate())
XCTAssertNil(pattern.range(for: "dog, 🐕, , イヌ"))
}