Skip to content

Commit 050c3e3

Browse files
Added editor overscroll setting (#2010)
1 parent 255c88e commit 050c3e3

File tree

5 files changed

+68
-20
lines changed

5 files changed

+68
-20
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
6C81916B29B41DD300B75C92 /* DequeModule in Frameworks */ = {isa = PBXBuildFile; productRef = 6C81916A29B41DD300B75C92 /* DequeModule */; };
2929
6C85BB402C2105ED00EB5DEF /* CodeEditKit in Frameworks */ = {isa = PBXBuildFile; productRef = 6C85BB3F2C2105ED00EB5DEF /* CodeEditKit */; };
3030
6C85BB442C210EFD00EB5DEF /* SwiftUIIntrospect in Frameworks */ = {isa = PBXBuildFile; productRef = 6C85BB432C210EFD00EB5DEF /* SwiftUIIntrospect */; };
31-
6C9DB9E42D55656300ACD86E /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6C9DB9E32D55656300ACD86E /* CodeEditSourceEditor */; };
3231
6CAAF68A29BC9C2300A1F48A /* (null) in Sources */ = {isa = PBXBuildFile; };
3332
6CAAF69229BCC71C00A1F48A /* (null) in Sources */ = {isa = PBXBuildFile; };
3433
6CAAF69429BCD78600A1F48A /* (null) in Sources */ = {isa = PBXBuildFile; };
@@ -185,7 +184,6 @@
185184
6C0824A12C5C0C9700A0751E /* SwiftTerm in Frameworks */,
186185
6C81916B29B41DD300B75C92 /* DequeModule in Frameworks */,
187186
6CB94D032CA1205100E8651C /* AsyncAlgorithms in Frameworks */,
188-
6C9DB9E42D55656300ACD86E /* CodeEditSourceEditor in Frameworks */,
189187
);
190188
runOnlyForDeploymentPostprocessing = 0;
191189
};
@@ -319,7 +317,6 @@
319317
6CB94D022CA1205100E8651C /* AsyncAlgorithms */,
320318
6CC00A8A2CBEF150004E8134 /* CodeEditSourceEditor */,
321319
6C73A6D22D4F1E550012D95C /* CodeEditSourceEditor */,
322-
6C9DB9E32D55656300ACD86E /* CodeEditSourceEditor */,
323320
);
324321
productName = CodeEdit;
325322
productReference = B658FB2C27DA9E0F00EA4DBD /* CodeEdit.app */;
@@ -422,7 +419,7 @@
422419
303E88462C276FD600EEA8D9 /* XCRemoteSwiftPackageReference "LanguageServerProtocol" */,
423420
6C4E37FA2C73E00700AEE7B5 /* XCRemoteSwiftPackageReference "SwiftTerm" */,
424421
6CB94D012CA1205100E8651C /* XCRemoteSwiftPackageReference "swift-async-algorithms" */,
425-
6C9DB9E22D55656300ACD86E /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */,
422+
30597BCA2D9AA5BE004BC2CC /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */,
426423
);
427424
preferredProjectObjectVersion = 55;
428425
productRefGroup = B658FB2D27DA9E0F00EA4DBD /* Products */;
@@ -1652,6 +1649,14 @@
16521649
minimumVersion = 0.13.2;
16531650
};
16541651
};
1652+
30597BCA2D9AA5BE004BC2CC /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */ = {
1653+
isa = XCRemoteSwiftPackageReference;
1654+
repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor.git";
1655+
requirement = {
1656+
kind = upToNextMajorVersion;
1657+
minimumVersion = 0.10.0;
1658+
};
1659+
};
16551660
30CB648F2C16CA8100CC8A9E /* XCRemoteSwiftPackageReference "LanguageServerProtocol" */ = {
16561661
isa = XCRemoteSwiftPackageReference;
16571662
repositoryURL = "https://github.com/ChimeHQ/LanguageServerProtocol";
@@ -1740,14 +1745,6 @@
17401745
minimumVersion = 1.2.0;
17411746
};
17421747
};
1743-
6C9DB9E22D55656300ACD86E /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */ = {
1744-
isa = XCRemoteSwiftPackageReference;
1745-
repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor";
1746-
requirement = {
1747-
kind = upToNextMajorVersion;
1748-
minimumVersion = 0.10.0;
1749-
};
1750-
};
17511748
6CB94D012CA1205100E8651C /* XCRemoteSwiftPackageReference "swift-async-algorithms" */ = {
17521749
isa = XCRemoteSwiftPackageReference;
17531750
repositoryURL = "https://github.com/apple/swift-async-algorithms.git";
@@ -1841,11 +1838,6 @@
18411838
package = 6C85BB422C210EFD00EB5DEF /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */;
18421839
productName = SwiftUIIntrospect;
18431840
};
1844-
6C9DB9E32D55656300ACD86E /* CodeEditSourceEditor */ = {
1845-
isa = XCSwiftPackageProductDependency;
1846-
package = 6C9DB9E22D55656300ACD86E /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */;
1847-
productName = CodeEditSourceEditor;
1848-
};
18491841
6CB4463F2B6DFF3A00539ED0 /* CodeEditSourceEditor */ = {
18501842
isa = XCSwiftPackageProductDependency;
18511843
productName = CodeEditSourceEditor;

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CodeEdit/Features/Editor/Views/CodeFileView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ struct CodeFileView: View {
3030
var lineHeightMultiple
3131
@AppSettings(\.textEditing.wrapLinesToEditorWidth)
3232
var wrapLinesToEditorWidth
33+
@AppSettings(\.textEditing.overscroll)
34+
var overscroll
3335
@AppSettings(\.textEditing.font)
3436
var settingsFont
3537
@AppSettings(\.theme.useThemeBackground)
@@ -127,6 +129,7 @@ struct CodeFileView: View {
127129
indentOption: (codeFile.indentOption ?? indentOption).textViewOption(),
128130
lineHeight: lineHeightMultiple,
129131
wrapLines: codeFile.wrapLines ?? wrapLinesToEditorWidth,
132+
editorOverscroll: overscroll.overscrollPercentage,
130133
cursorPositions: $cursorPositions,
131134
useThemeBackground: useThemeBackground,
132135
contentInsets: edgeInsets.nsEdgeInsets,

CodeEdit/Features/Settings/Pages/TextEditingSettings/Models/TextEditingSettings.swift

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ extension SettingsData {
1414
struct TextEditingSettings: Codable, Hashable, SearchableSettingsPage {
1515

1616
var searchKeys: [String] {
17-
[
17+
var keys = [
1818
"Prefer Indent Using",
1919
"Tab Width",
2020
"Wrap lines to editor width",
21+
"Editor Overscroll",
2122
"Font",
2223
"Font Size",
2324
"Font Weight",
@@ -27,7 +28,10 @@ extension SettingsData {
2728
"Enable type-over completion",
2829
"Bracket Pair Highlight"
2930
]
30-
.map { NSLocalizedString($0, comment: "") }
31+
if #available(macOS 14.0, *) {
32+
keys.append("System Cursor")
33+
}
34+
return keys.map { NSLocalizedString($0, comment: "") }
3135
}
3236

3337
/// An integer indicating how many spaces a `tab` will appear as visually.
@@ -49,6 +53,9 @@ extension SettingsData {
4953
/// A flag indicating whether to wrap lines to editor width
5054
var wrapLinesToEditorWidth: Bool = true
5155

56+
/// The percentage of overscroll to apply to the text view
57+
var overscroll: OverscrollOption = .medium
58+
5259
/// A multiplier for setting the line height. Defaults to `1.2`
5360
var lineHeightMultiple: Double = 1.2
5461

@@ -88,6 +95,10 @@ extension SettingsData {
8895
Bool.self,
8996
forKey: .wrapLinesToEditorWidth
9097
) ?? true
98+
self.overscroll = try container.decodeIfPresent(
99+
OverscrollOption.self,
100+
forKey: .overscroll
101+
) ?? .medium
91102
self.lineHeightMultiple = try container.decodeIfPresent(
92103
Double.self,
93104
forKey: .lineHeightMultiple
@@ -167,6 +178,22 @@ extension SettingsData {
167178
case underline
168179
}
169180
}
181+
182+
enum OverscrollOption: String, Codable {
183+
case none
184+
case small
185+
case medium
186+
case large
187+
188+
var overscrollPercentage: CGFloat {
189+
switch self {
190+
case .none: return 0
191+
case .small: return 0.25
192+
case .medium: return 0.5
193+
case .large: return 0.75
194+
}
195+
}
196+
}
170197
}
171198

172199
struct EditorFont: Codable, Hashable {

CodeEdit/Features/Settings/Pages/TextEditingSettings/TextEditingSettingsView.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct TextEditingSettingsView: View {
1919
defaultTabWidth
2020
wrapLinesToEditorWidth
2121
useSystemCursor
22+
overscroll
2223
}
2324
Section {
2425
fontSelector
@@ -80,6 +81,31 @@ private extension TextEditingSettingsView {
8081
}
8182
}
8283

84+
@ViewBuilder private var overscroll: some View {
85+
Group {
86+
Picker(
87+
"Editor Overscroll",
88+
selection: $textEditing.overscroll
89+
) {
90+
Text("None")
91+
.tag(SettingsData.TextEditingSettings.OverscrollOption.none)
92+
Divider()
93+
Text("Small")
94+
.tag(
95+
SettingsData.TextEditingSettings.OverscrollOption.small
96+
)
97+
Text("Medium")
98+
.tag(
99+
SettingsData.TextEditingSettings.OverscrollOption.medium
100+
)
101+
Text("Large")
102+
.tag(
103+
SettingsData.TextEditingSettings.OverscrollOption.large
104+
)
105+
}
106+
}
107+
}
108+
83109
@ViewBuilder private var lineHeight: some View {
84110
Stepper(
85111
"Line Height",

0 commit comments

Comments
 (0)