Fast typing in large files !200
merged
merged by cmc on 2026-10-10 05:02 UTC
· krz/orgstar:typing-speed into main
6 files changed, +36 −10
Layout: unified · split
Sources/OrgCore/Parser/Incremental.swift
+1 −1
| @@ -89,7 +89,7 @@ private struct ReparseContext { |
| 89 | break |
89 | break |
| 90 | } |
90 | } |
| 91 | } |
91 | } |
| 92 | return movesBoundary && Self.settingsKeys.contains { newText.range(of: "#+\($0):", options: .caseInsensitive) != nil } |
92 | return movesBoundary && Self.settingsKeys.contains { newText.containsIgnoringASCIICase("#+\($0):") } |
| 93 | } |
93 | } |
| 94 | |
94 | |
| 95 | // MARK: - Element |
95 | // MARK: - Element |
Sources/OrgstarMobile/AgendaScreen.swift
+10 −3
| @@ -91,7 +91,7 @@ struct AgendaScreen: View, Equatable { |
| 91 | } else { |
91 | } else { |
| 92 | let rows = agenda.list.filter(filter.keeps).compactMap { AgendaRow(item: $0, day: agenda.today, today: agenda.today) } |
92 | let rows = agenda.list.filter(filter.keeps).compactMap { AgendaRow(item: $0, day: agenda.today, today: agenda.today) } |
| 93 | if rows.isEmpty, !agenda.isComputing { Text("No entries").foregroundStyle(.secondary) } |
93 | if rows.isEmpty, !agenda.isComputing { Text("No entries").foregroundStyle(.secondary) } |
| 94 | ForEach(rows) { row($0, day: agenda.today) } |
94 | ForEach(rows) { item in Deferred { row(item, day: agenda.today) } } |
| 95 | } |
95 | } |
| 96 | if let reminderStatus { |
96 | if let reminderStatus { |
| 97 | Section { } footer: { Text(reminderStatus) } |
97 | Section { } footer: { Text(reminderStatus) } |
| @@ -276,7 +276,7 @@ struct AgendaScreen: View, Equatable { |
| 276 | } |
276 | } |
| 277 | .buttonStyle(.plain) |
277 | .buttonStyle(.plain) |
| 278 | if overdueExpanded { |
278 | if overdueExpanded { |
| 279 | ForEach(group.overdue) { row($0, day: group.day) } |
279 | ForEach(group.overdue) { item in Deferred { row(item, day: group.day) } } |
| 280 | } |
280 | } |
| 281 | } |
281 | } |
| 282 | if group.isEmpty { |
282 | if group.isEmpty { |
| @@ -286,7 +286,7 @@ struct AgendaScreen: View, Equatable { |
| 286 | ForEach(lines(group)) { line in |
286 | ForEach(lines(group)) { line in |
| 287 | switch line { |
287 | switch line { |
| 288 | case .now: NowLine(time: now, color: todayColor) |
288 | case .now: NowLine(time: now, color: todayColor) |
| 289 | case .row(let item): row(item, day: group.day) |
289 | case .row(let item): Deferred { row(item, day: group.day) } |
| 290 | } |
290 | } |
| 291 | } |
291 | } |
| 292 | } |
292 | } |
| @@ -918,4 +918,11 @@ struct RefileSheet: View { |
| 918 | } |
918 | } |
| 919 | } |
919 | } |
| 920 | } |
920 | } |
| |
921 | /// A view built when the list draws it: a list makes every row's view up front, and a row's |
| |
922 | /// actions and menus cost more than the row. |
| |
923 | private struct Deferred<Content: View>: View { |
| |
924 | @ViewBuilder let content: () -> Content |
| |
925 | |
| |
926 | var body: some View { content() } |
| |
927 | } |
| 921 | #endif |
928 | #endif |
Sources/OrgstarMobile/EditorScreen.swift
+13 −4
| @@ -436,10 +436,12 @@ struct CommandPalette: View { |
| 436 | ("org.table.expand", "Expand Table Columns"), |
436 | ("org.table.expand", "Expand Table Columns"), |
| 437 | ] |
437 | ] |
| 438 | |
438 | |
| |
439 | /// The commands that apply at the caret and their keys, worked out once when the palette |
| |
440 | /// opens rather than on every keystroke in the search field. |
| |
441 | @State private var applicable: [(id: String, title: String, keys: String?)]? |
| |
442 | |
| 439 | var body: some View { |
443 | var body: some View { |
| 440 | let context = editor.editContext() |
444 | let shown = (applicable ?? []).filter { query.isEmpty || $0.title.localizedCaseInsensitiveContains(query) } |
| 441 | let all = Self.viewCommands + Commands.everything.map { ($0.id, $0.title) } |
| |
| 442 | let shown = all.filter { editor.applies($0.id, in: context) && (query.isEmpty || $0.title.localizedCaseInsensitiveContains(query)) } |
| |
| 443 | NavigationStack { |
445 | NavigationStack { |
| 444 | List(shown, id: \.id) { command in |
446 | List(shown, id: \.id) { command in |
| 445 | Button { |
447 | Button { |
| @@ -449,7 +451,7 @@ struct CommandPalette: View { |
| 449 | HStack { |
451 | HStack { |
| 450 | Text(command.title).foregroundStyle(.primary) |
452 | Text(command.title).foregroundStyle(.primary) |
| 451 | Spacer() |
453 | Spacer() |
| 452 | if let keys = editor.keymap.keyLabels(for: command.id).first { |
454 | if let keys = command.keys { |
| 453 | Text(keys).font(.caption.monospaced()).foregroundStyle(.secondary) |
455 | Text(keys).font(.caption.monospaced()).foregroundStyle(.secondary) |
| 454 | } |
456 | } |
| 455 | } |
457 | } |
| @@ -460,6 +462,13 @@ struct CommandPalette: View { |
| 460 | .navigationBarTitleDisplayMode(.inline) |
462 | .navigationBarTitleDisplayMode(.inline) |
| 461 | .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Close") { dismiss() } } } |
463 | .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Close") { dismiss() } } } |
| 462 | } |
464 | } |
| |
465 | .onAppear { |
| |
466 | guard applicable == nil else { return } |
| |
467 | let context = editor.editContext() |
| |
468 | applicable = (Self.viewCommands + Commands.everything.map { ($0.id, $0.title) }) |
| |
469 | .filter { editor.applies($0.id, in: context) } |
| |
470 | .map { ($0.id, $0.title, editor.keymap.keyLabels(for: $0.id).first) } |
| |
471 | } |
| 463 | } |
472 | } |
| 464 | } |
473 | } |
| 465 | #endif |
474 | #endif |
Sources/OrgstarMobile/OrgstarMobileApp.swift
+3
| @@ -12,8 +12,11 @@ struct OrgstarMobileApp: App { |
| 12 | @State private var model = MobileModel.shared |
12 | @State private var model = MobileModel.shared |
| 13 | |
13 | |
| 14 | init() { |
14 | init() { |
| |
15 | // Debug builds, and runs from Xcode, whose scheme sets ORGSTAR_PERF. |
| 15 | #if DEBUG |
16 | #if DEBUG |
| 16 | Perf.watchMainThread() |
17 | Perf.watchMainThread() |
| |
18 | #else |
| |
19 | if ProcessInfo.processInfo.environment["ORGSTAR_PERF"] != nil { Perf.watchMainThread() } |
| 17 | #endif |
20 | #endif |
| 18 | LiveClock.install() |
21 | LiveClock.install() |
| 19 | } |
22 | } |
Sources/OrgstarMobile/SearchScreen.swift
+1 −1
| @@ -23,7 +23,7 @@ struct SearchScreen: View { |
| 23 | } |
23 | } |
| 24 | } |
24 | } |
| 25 | } |
25 | } |
| 26 | let headings = workspace.search(trimmed, overlay: workspace.overlay(session.openDocuments)) |
26 | let headings = Perf.measure("search.headings") { workspace.search(trimmed, overlay: workspace.overlay(session.openDocuments)) } |
| 27 | Section("Headings") { |
27 | Section("Headings") { |
| 28 | if headings.isEmpty { Text("No headings match").foregroundStyle(.secondary) } |
28 | if headings.isEmpty { Text("No headings match").foregroundStyle(.secondary) } |
| 29 | ForEach(headings, id: \.self) { location in |
29 | ForEach(headings, id: \.self) { location in |
ios/Orgstar.xcodeproj/xcshareddata/xcschemes/Orgstar iOS.xcscheme
+8 −1
| @@ -29,7 +29,7 @@ |
| 29 | shouldUseLaunchSchemeArgsEnv = "YES"> |
29 | shouldUseLaunchSchemeArgsEnv = "YES"> |
| 30 | </TestAction> |
30 | </TestAction> |
| 31 | <LaunchAction |
31 | <LaunchAction |
| 32 | buildConfiguration = "Debug" |
32 | buildConfiguration = "Release" |
| 33 | selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
33 | selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
| 34 | selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
34 | selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
| 35 | launchStyle = "0" |
35 | launchStyle = "0" |
| @@ -48,6 +48,13 @@ |
| 48 | ReferencedContainer = "container:Orgstar.xcodeproj"> |
48 | ReferencedContainer = "container:Orgstar.xcodeproj"> |
| 49 | </BuildableReference> |
49 | </BuildableReference> |
| 50 | </BuildableProductRunnable> |
50 | </BuildableProductRunnable> |
| |
51 | <EnvironmentVariables> |
| |
52 | <EnvironmentVariable |
| |
53 | key = "ORGSTAR_PERF" |
| |
54 | value = "1" |
| |
55 | isEnabled = "YES"> |
| |
56 | </EnvironmentVariable> |
| |
57 | </EnvironmentVariables> |
| 51 | </LaunchAction> |
58 | </LaunchAction> |
| 52 | <ProfileAction |
59 | <ProfileAction |
| 53 | buildConfiguration = "Release" |
60 | buildConfiguration = "Release" |