Skip to content

Commit f72e461

Browse files
committed
Bump CESE (bugfix), Add Test For Scroll Position
1 parent 08adf15 commit f72e461

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@
17661766
repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor";
17671767
requirement = {
17681768
kind = exactVersion;
1769-
version = 0.14.0;
1769+
version = 0.14.1;
17701770
};
17711771
};
17721772
6C85BB3E2C2105ED00EB5DEF /* XCRemoteSwiftPackageReference "CodeEditKit" */ = {

CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CodeEdit/Features/Editor/Models/Restoration/EditorStateRestoration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class EditorStateRestoration {
3838
let data: Data
3939
}
4040

41-
struct StateRestorationData: Codable {
41+
struct StateRestorationData: Codable, Equatable {
4242
// Cursor positions as range values (not row/column!)
4343
let cursorPositions: [Range<Int>]
4444
let scrollPositionX: Double

CodeEditTests/Features/Editor/EditorStateRestorationTests.swift

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct EditorStateRestorationTests {
2121
}
2222

2323
@Test
24-
func savesAndRetrievesState() throws {
24+
func savesAndRetrievesStateForFile() throws {
2525
try withTempDir { dir in
2626
let url = dir.appending(path: "database.db")
2727
let restoration = try EditorStateRestoration(url)
@@ -33,7 +33,33 @@ struct EditorStateRestorationTests {
3333
)
3434

3535
// Retrieve it
36-
#expect(restoration.restorationState(for: dir.appending(path: "file.txt")) != nil)
36+
#expect(
37+
restoration.restorationState(for: dir.appending(path: "file.txt"))
38+
== EditorStateRestoration.StateRestorationData(cursorPositions: [], scrollPosition: .zero)
39+
)
40+
}
41+
}
42+
43+
@Test
44+
func savesScrollPosition() throws {
45+
try withTempDir { dir in
46+
let url = dir.appending(path: "database.db")
47+
let restoration = try EditorStateRestoration(url)
48+
49+
// Update some state
50+
restoration.updateRestorationState(
51+
for: dir.appending(path: "file.txt"),
52+
data: .init(cursorPositions: [], scrollPosition: CGPoint(x: 100, y: 100))
53+
)
54+
55+
// Retrieve it
56+
#expect(
57+
restoration.restorationState(for: dir.appending(path: "file.txt"))
58+
== EditorStateRestoration.StateRestorationData(
59+
cursorPositions: [],
60+
scrollPosition: CGPoint(x: 100, y: 100)
61+
)
62+
)
3763
}
3864
}
3965

0 commit comments

Comments
 (0)