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 | 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 | 95 | // MARK: - Element |
Sources/OrgstarMobile/AgendaScreen.swift
+10 −3
| @@ -91,7 +91,7 @@ struct AgendaScreen: View, Equatable { |
| 91 | 91 | } else { |
| 92 | 92 | let rows = agenda.list.filter(filter.keeps).compactMap { AgendaRow(item: $0, day: agenda.today, today: agenda.today) } |
| 93 | 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 | 96 | if let reminderStatus { |
| 97 | 97 | Section { } footer: { Text(reminderStatus) } |
| @@ -276,7 +276,7 @@ struct AgendaScreen: View, Equatable { |
| 276 | 276 | } |
| 277 | 277 | .buttonStyle(.plain) |
| 278 | 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 | 282 | if group.isEmpty { |
| @@ -286,7 +286,7 @@ struct AgendaScreen: View, Equatable { |
| 286 | 286 | ForEach(lines(group)) { line in |
| 287 | 287 | switch line { |
| 288 | 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 | 928 | #endif |
Sources/OrgstarMobile/EditorScreen.swift
+13 −4
| @@ -436,10 +436,12 @@ struct CommandPalette: View { |
| 436 | 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 | 443 | var body: some View { |
| 440 | | let context = editor.editContext() |
| 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)) } |
| 444 | let shown = (applicable ?? []).filter { query.isEmpty || $0.title.localizedCaseInsensitiveContains(query) } |
| 443 | 445 | NavigationStack { |
| 444 | 446 | List(shown, id: \.id) { command in |
| 445 | 447 | Button { |
| @@ -449,7 +451,7 @@ struct CommandPalette: View { |
| 449 | 451 | HStack { |
| 450 | 452 | Text(command.title).foregroundStyle(.primary) |
| 451 | 453 | Spacer() |
| 452 | | if let keys = editor.keymap.keyLabels(for: command.id).first { |
| 454 | if let keys = command.keys { |
| 453 | 455 | Text(keys).font(.caption.monospaced()).foregroundStyle(.secondary) |
| 454 | 456 | } |
| 455 | 457 | } |
| @@ -460,6 +462,13 @@ struct CommandPalette: View { |
| 460 | 462 | .navigationBarTitleDisplayMode(.inline) |
| 461 | 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 | 474 | #endif |
Sources/OrgstarMobile/OrgstarMobileApp.swift
+3
| @@ -12,8 +12,11 @@ struct OrgstarMobileApp: App { |
| 12 | 12 | @State private var model = MobileModel.shared |
| 13 | 13 | |
| 14 | 14 | init() { |
| 15 | // Debug builds, and runs from Xcode, whose scheme sets ORGSTAR_PERF. |
| 15 | 16 | #if DEBUG |
| 16 | 17 | Perf.watchMainThread() |
| 18 | #else |
| 19 | if ProcessInfo.processInfo.environment["ORGSTAR_PERF"] != nil { Perf.watchMainThread() } |
| 17 | 20 | #endif |
| 18 | 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 | 27 | Section("Headings") { |
| 28 | 28 | if headings.isEmpty { Text("No headings match").foregroundStyle(.secondary) } |
| 29 | 29 | ForEach(headings, id: \.self) { location in |
ios/Orgstar.xcodeproj/xcshareddata/xcschemes/Orgstar iOS.xcscheme
+8 −1
| @@ -29,7 +29,7 @@ |
| 29 | 29 | shouldUseLaunchSchemeArgsEnv = "YES"> |
| 30 | 30 | </TestAction> |
| 31 | 31 | <LaunchAction |
| 32 | | buildConfiguration = "Debug" |
| 32 | buildConfiguration = "Release" |
| 33 | 33 | selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
| 34 | 34 | selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
| 35 | 35 | launchStyle = "0" |
| @@ -48,6 +48,13 @@ |
| 48 | 48 | ReferencedContainer = "container:Orgstar.xcodeproj"> |
| 49 | 49 | </BuildableReference> |
| 50 | 50 | </BuildableProductRunnable> |
| 51 | <EnvironmentVariables> |
| 52 | <EnvironmentVariable |
| 53 | key = "ORGSTAR_PERF" |
| 54 | value = "1" |
| 55 | isEnabled = "YES"> |
| 56 | </EnvironmentVariable> |
| 57 | </EnvironmentVariables> |
| 51 | 58 | </LaunchAction> |
| 52 | 59 | <ProfileAction |
| 53 | 60 | buildConfiguration = "Release" |