Completion: opens by itself, fuzzy, words, index !483

merged merged by cmc on 2026-11-26 05:35 UTC · krz/orgstar:m4-completion into main

14 files changed, +1383 −73

One commit's changes, read-only. Review comments go on all commits.

Layout: unified · split

Changed files (14)
Sources/OrgApp/OrgPreferences.swift +15 · view
@@ -54,6 +54,7 @@ public enum OrgPreferences {
54 options.clockInSwitchToState = string("clockInSwitchToState", defaults).nonEmpty 54 options.clockInSwitchToState = string("clockInSwitchToState", defaults).nonEmpty
55 options.timerFormat = string("timerFormat", defaults).contains("%s") ? string("timerFormat", defaults) : "%s " 55 options.timerFormat = string("timerFormat", defaults).contains("%s") ? string("timerFormat", defaults) : "%s "
56 options.timerDefault = string("timerDefault", defaults).nonEmpty ?? "0" 56 options.timerDefault = string("timerDefault", defaults).nonEmpty ?? "0"
57 options.completion = completion(defaults)
57 let templates = UserConfig.structureTemplates(defaults) 58 let templates = UserConfig.structureTemplates(defaults)
58 options.structureTemplates = templates.isEmpty ? nil : StructureTemplate.merged(templates) 59 options.structureTemplates = templates.isEmpty ? nil : StructureTemplate.merged(templates)
59 options.trackOrderedPropertyWithTag = switch string("trackOrderedTag", defaults) { 60 options.trackOrderedPropertyWithTag = switch string("trackOrderedTag", defaults) {
@@ -64,6 +65,20 @@ public enum OrgPreferences {
64 return options 65 return options
65 } 66 }
66 67
68 /// The completion settings, `preset` resolved by the keymap preset: Doom's corfu opens
69 /// the list by itself and matches with orderless; Emacs and the Mac keys do neither.
70 public static func completion(_ defaults: UserDefaults = .standard) -> CompletionOptions {
71 let doom = string("keymap", defaults) == "doom"
72 func choice(_ key: String, on: String) -> Bool {
73 let value = string(key, defaults)
74 return value == "preset" ? doom : value == on
75 }
76 return CompletionOptions(
77 auto: choice("completionAuto", on: "on"), delay: Double(max(0, integer("completionAutoDelay", defaults))) / 1000,
78 prefix: max(1, integer("completionAutoPrefix", defaults)), fuzzy: choice("completionStyle", on: "fuzzy"), words: bool("completionWords", defaults)
79 )
80 }
81
67 /// `colors` with the type settings of `[theme]`: font, size, line spacing, heading step. 82 /// `colors` with the type settings of `[theme]`: font, size, line spacing, heading step.
68 public static func theme(_ colors: ThemeSpec, _ defaults: UserDefaults = .standard) -> ThemeSpec { 83 public static func theme(_ colors: ThemeSpec, _ defaults: UserDefaults = .standard) -> ThemeSpec {
69 var spec = colors 84 var spec = colors
Sources/OrgApp/UserConfig.swift +10 · view
@@ -360,6 +360,16 @@ public enum UserConfig {
360 Setting(section: "orgstar", key: "option-as-meta", defaultsKey: "optionAsMeta", 360 Setting(section: "orgstar", key: "option-as-meta", defaultsKey: "optionAsMeta",
361 kind: .integerChoice([("left", 1), ("right", 2), ("both", 3), ("none", 0)]), fallback: .string("left"), 361 kind: .integerChoice([("left", 1), ("right", 2), ("both", 3), ("none", 0)]), fallback: .string("left"),
362 comment: "left, right, both or none", legacy: "general.option-as-meta"), 362 comment: "left, right, both or none", legacy: "general.option-as-meta"),
363 Setting(section: "orgstar", key: "completion-auto", defaultsKey: "completionAuto", kind: .choice([("preset", "preset"), ("on", "on"), ("off", "off")]),
364 fallback: .string("preset"), comment: "the completion list opens by itself as you type: on, off, or preset (on with doom keys, off with emacs and mac)", legacy: ""),
365 Setting(section: "orgstar", key: "completion-auto-delay", defaultsKey: "completionAutoDelay", kind: .integer, fallback: .integer(400),
366 comment: "milliseconds after typing stops before the list opens by itself (corfu-auto-delay)", legacy: ""),
367 Setting(section: "orgstar", key: "completion-auto-prefix", defaultsKey: "completionAutoPrefix", kind: .integer, fallback: .integer(2),
368 comment: "characters typed before the list opens by itself (corfu-auto-prefix)", legacy: ""),
369 Setting(section: "orgstar", key: "completion-style", defaultsKey: "completionStyle", kind: .choice([("preset", "preset"), ("prefix", "prefix"), ("fuzzy", "fuzzy")]),
370 fallback: .string("preset"), comment: "prefix: candidates start with what you typed; fuzzy: its letters in order, best first; preset: fuzzy with doom keys, prefix with emacs and mac", legacy: ""),
371 Setting(section: "orgstar", key: "completion-words", defaultsKey: "completionWords", kind: .bool, fallback: .bool(false),
372 comment: "the list that opens by itself offers words from your buffers and folders where Org offers nothing", legacy: ""),
363 Setting(section: "orgstar", key: "pdf-margin", defaultsKey: "pdfMargin", kind: .integer, fallback: .integer(50), 373 Setting(section: "orgstar", key: "pdf-margin", defaultsKey: "pdfMargin", kind: .integer, fallback: .integer(50),
364 comment: "PDF export's page margins, in points", legacy: ""), 374 comment: "PDF export's page margins, in points", legacy: ""),
365 Setting(section: "orgstar", key: "pdf-font", defaultsKey: "pdfFont", kind: .string, fallback: .string(""), 375 Setting(section: "orgstar", key: "pdf-font", defaultsKey: "pdfFont", kind: .string, fallback: .string(""),
Sources/OrgCore/Commands/Command.swift +2 · view
@@ -99,6 +99,8 @@ public struct EditingOptions: Sendable, Equatable, Codable {
99 public var timerDefault = "0" 99 public var timerDefault = "0"
100 /// The snippets and file templates of `snippets.toml`. 100 /// The snippets and file templates of `snippets.toml`.
101 public var snippets: [Snippet] = [] 101 public var snippets: [Snippet] = []
102 /// How the completion list opens and matches.
103 public var completion = CompletionOptions()
102 104
103 public init( 105 public init(
104 tagsColumn: Int = -77, insertHeadingRespectContent: Bool = false, metaReturnMaySplitLine: Bool = true, 106 tagsColumn: Int = -77, insertHeadingRespectContent: Bool = false, metaReturnMaySplitLine: Bool = true,
Sources/OrgCore/Completion/CompletionList.swift added +162 · view
@@ -0,0 +1,162 @@
1import Foundation
2
3/// How the completion list behaves, from `config.toml`, with the preset's choices resolved.
4public struct CompletionOptions: Sendable, Equatable, Codable {
5 /// The list opens by itself after typing (`corfu-auto`).
6 public var auto = false
7 /// The pause after typing before it opens, in seconds (`corfu-auto-delay`).
8 public var delay = 0.4
9 /// Characters typed before it opens (`corfu-auto-prefix`).
10 public var prefix = 2
11 /// Candidates match when the typed characters appear in order, best first, as the
12 /// palette matches; otherwise they start with what's typed.
13 public var fuzzy = false
14 /// Words from the buffers and the index fill the list that opens by itself where Org
15 /// offers nothing.
16 public var words = false
17
18 public init(auto: Bool = false, delay: Double = 0.4, prefix: Int = 2, fuzzy: Bool = false, words: Bool = false) {
19 self.auto = auto
20 self.delay = delay
21 self.prefix = prefix
22 self.fuzzy = fuzzy
23 self.words = words
24 }
25}
26
27/// When the list opens by itself.
28public enum CompletionAuto {
29 /// The pause after a change before the list opens, or nil when it doesn't: the setting is
30 /// off, Vim keys are outside insert state, or the file isn't org and words aren't offered.
31 public static func delay(_ options: CompletionOptions, modal: Bool, insertState: Bool, isOrg: Bool) -> Double? {
32 guard options.auto, !modal || insertState, isOrg || options.words else { return nil }
33 return max(0, options.delay)
34 }
35
36 /// Whether `completion`, found after the pause, opens the list: enough typed, and
37 /// something to show now or from the index.
38 public static func opens(_ completion: Completion?, _ options: CompletionOptions) -> Bool {
39 guard let completion, completion.range.count >= max(1, options.prefix) else { return false }
40 return !completion.candidates.isEmpty || completion.query != nil
41 }
42}
43
44/// The open list, as corfu keeps it: the completion shown and the chosen row, nil while the
45/// typed text stands (`corfu-preselect` prompt).
46public struct CompletionList: Sendable, Equatable {
47 public private(set) var completion: Completion
48 public private(set) var selection: Int?
49
50 public init(_ completion: Completion, selection: Int? = nil) {
51 self.completion = completion
52 self.selection = selection.flatMap { completion.candidates.indices.contains($0) ? $0 : nil }
53 }
54
55 /// New candidates; the chosen one stays chosen if it is still there.
56 public mutating func update(_ completion: Completion) {
57 if completion.candidates != self.completion.candidates { selection = selected.flatMap { completion.candidates.firstIndex(of: $0) } }
58 self.completion = completion
59 }
60
61 /// corfu-cycle: past either end the choice wraps through the typed text.
62 public mutating func move(_ delta: Int) {
63 let count = completion.candidates.count
64 guard count > 0 else { return }
65 if let s = selection {
66 let next = s + delta
67 selection = next < 0 || next >= count ? nil : next
68 } else {
69 selection = delta > 0 ? 0 : count - 1
70 }
71 }
72
73 public var selected: String? { selection.map { completion.candidates[$0] } }
74
75 /// The rows shown when at most `rows` fit: those around the choice.
76 public func visible(rows: Int) -> Range<Int> {
77 let count = completion.candidates.count
78 let first = max(0, min((selection ?? 0) - rows + 1, count - rows))
79 return first..<min(count, first + rows)
80 }
81
82 public enum Action: Equatable {
83 /// The choice moved, or the key did nothing more; show the list again.
84 case shown
85 /// Insert this candidate and close the list.
86 case insert(String)
87 /// Insert the part the candidates share, keeping the list open.
88 case common(String)
89 /// Close the list.
90 case close
91 /// Close the list and let the key do what it otherwise does.
92 case closeAndPass
93 /// Not the list's key.
94 case pass
95 }
96
97 /// What a key does while the list is open.
98 public mutating func key(_ chord: KeyChord) -> Action {
99 switch chord {
100 case KeyChord("n", .control), KeyChord("<down>"), KeyChord("j", .control):
101 move(1)
102 return .shown
103 case KeyChord("p", .control), KeyChord("<up>"), KeyChord("k", .control):
104 move(-1)
105 return .shown
106 case KeyChord("TAB"):
107 // corfu-complete: the choice, else the candidates' common start.
108 let candidates = completion.candidates
109 if let selected { return .insert(selected) }
110 if candidates.count == 1 { return .insert(candidates[0]) }
111 guard let first = candidates.first, ![.template, .snippet, .idLink, .denoteLink].contains(completion.kind) else { return .shown }
112 let common = candidates.dropFirst().reduce(first) { $0.commonPrefix(with: $1) }
113 if common.utf16.count > completion.range.count, common.lowercased().hasPrefix(completion.typed.lowercased()) { return .common(common) }
114 return .shown
115 case KeyChord("RET"):
116 return selected.map { .insert($0) } ?? .closeAndPass
117 case KeyChord("ESC"):
118 return .closeAndPass
119 case KeyChord("g", .control):
120 return .close
121 default:
122 return .pass
123 }
124 }
125}
126
127/// The steps both editors take with a list: finding the completion at the caret again as
128/// typing goes on, and inserting a link.
129public enum CompletionFlow {
130 /// The index's answer for the completion of `kind` starting at `start`.
131 public typealias Fetched = (kind: Completion.Kind, start: Int, result: CompletionResult)
132
133 /// The completion at the caret for a list showing `open`, or for a new list of words
134 /// (`words`) or of what Org offers. Words narrow what was found when the list opened;
135 /// the rest are found again, with the index's answer added when it was for this place.
136 public static func current(_ context: EditContext, open: Completion?, words: Bool, others: () -> [String], fetched: Fetched?) -> Completion? {
137 if let open, open.kind == .word {
138 guard let range = Dabbrev.abbreviation(in: context.text, caret: context.caret), range.lowerBound == open.range.lowerBound else { return nil }
139 return Dabbrev.narrowed(open, to: range, in: context.text)
140 }
141 guard let found = words ? Dabbrev.completion(context, others: others()) : OrgCompletion.at(context) else { return nil }
142 if let fetched, fetched.kind == found.kind, fetched.start == found.range.lowerBound, found.query != nil {
143 return OrgCompletion.filled(found, with: fetched.result, fuzzy: context.options.completion.fuzzy)
144 }
145 return found
146 }
147
148 /// `org-id-get-create` on `item`'s heading in this buffer: the edits giving it `newID`.
149 public static func createID(_ item: CompletionItem, in context: EditContext, newID: String) -> [TextEdit]? {
150 let at = EditContext(revision: context.revision, text: context.text, tree: context.tree, selection: [item.start..<item.start], options: context.options)
151 guard case .commit(let result) = CreateID(newID: { newID }).run(in: at) else { return nil }
152 return result.edits
153 }
154
155 /// The edit putting the link to `item`, with `id`, in place of the link typed, after
156 /// `earlier` edits (an ID given in this buffer) moved the text.
157 public static func linkEdit(_ completion: Completion, _ item: CompletionItem, id: String, after earlier: [TextEdit] = []) -> TextEdit {
158 let range = completion.link ?? completion.range
159 let shift = earlier.filter { $0.range.upperBound <= range.lowerBound }.reduce(0) { $0 + $1.replacement.utf16.count - $1.range.count }
160 return TextEdit(range: (range.lowerBound + shift)..<(range.upperBound + shift), replacement: completion.link(item, id: id))
161 }
162}
Sources/OrgEditorAppKit/CompletionPopup.swift +150 −70 · view
@@ -9,12 +9,13 @@ final class CompletionPopup {
9 static let rows = 16 9 static let rows = 16
10 let window: NSPanel 10 let window: NSPanel
11 private let stack = NSStackView() 11 private let stack = NSStackView()
12 private(set) var completion: Completion 12 private(set) var list: CompletionList
13 /// The chosen row; nil while the typed text stands (`corfu-preselect` prompt).
14 private(set) var selection: Int?
15 13
16 init(_ completion: Completion) { 14 var completion: Completion { list.completion }
17 self.completion = completion 15 var selected: String? { list.selected }
16
17 init(_ completion: Completion, selection: Int? = nil) {
18 list = CompletionList(completion, selection: selection)
18 window = NSPanel(contentRect: NSRect(x: 0, y: 0, width: 200, height: 20), styleMask: [.borderless, .nonactivatingPanel], backing: .buffered, defer: true) 19 window = NSPanel(contentRect: NSRect(x: 0, y: 0, width: 200, height: 20), styleMask: [.borderless, .nonactivatingPanel], backing: .buffered, defer: true)
19 window.identifier = NSUserInterfaceItemIdentifier("completion") 20 window.identifier = NSUserInterfaceItemIdentifier("completion")
20 window.hasShadow = true 21 window.hasShadow = true
@@ -30,37 +31,24 @@ final class CompletionPopup {
30 window.contentView?.layer?.borderWidth = 1 31 window.contentView?.layer?.borderWidth = 1
31 } 32 }
32 33
33 func update(_ completion: Completion) { 34 func update(_ completion: Completion) { list.update(completion) }
34 if completion.candidates != self.completion.candidates { selection = nil }
35 self.completion = completion
36 }
37 35
38 func move(_ delta: Int) { 36 func move(_ delta: Int) { list.move(delta) }
39 let count = completion.candidates.count
40 guard count > 0 else { return }
41 // corfu-cycle: past either end wraps through the typed text.
42 if let s = selection {
43 let next = s + delta
44 selection = next < 0 || next >= count ? nil : next
45 } else {
46 selection = delta > 0 ? 0 : count - 1
47 }
48 }
49 37
50 var selected: String? { selection.map { completion.candidates[$0] } } 38 func key(_ chord: KeyChord) -> CompletionList.Action { list.key(chord) }
51 39
52 /// Lays the rows out and puts the list under `caret`, a rectangle in screen coordinates. 40 /// Lays the rows out and puts the list under `caret`, a rectangle in screen coordinates.
53 func show(under caret: NSRect, in parent: NSWindow?, font: NSFont) { 41 func show(under caret: NSRect, in parent: NSWindow?, font: NSFont) {
54 stack.arrangedSubviews.forEach { $0.removeFromSuperview() } 42 stack.arrangedSubviews.forEach { $0.removeFromSuperview() }
55 let candidates = completion.candidates 43 let candidates = completion.candidates
56 let first = max(0, min((selection ?? 0) - Self.rows + 1, candidates.count - Self.rows))
57 var width: CGFloat = 80 44 var width: CGFloat = 80
58 for (index, candidate) in candidates.enumerated().dropFirst(first).prefix(Self.rows) { 45 for index in list.visible(rows: Self.rows) {
46 let candidate = candidates[index]
59 let label = NSTextField(labelWithString: " " + completion.label(candidate) + (completion.kind == .snippet ? " " + String(localized: "snippet", comment: "Marks a snippet in the completion list") : "") + " ") 47 let label = NSTextField(labelWithString: " " + completion.label(candidate) + (completion.kind == .snippet ? " " + String(localized: "snippet", comment: "Marks a snippet in the completion list") : "") + " ")
60 label.font = font 48 label.font = font
61 label.drawsBackground = index == selection 49 label.drawsBackground = index == list.selection
62 label.backgroundColor = .selectedContentBackgroundColor 50 label.backgroundColor = .selectedContentBackgroundColor
63 label.textColor = index == selection ? .alternateSelectedControlTextColor : .labelColor 51 label.textColor = index == list.selection ? .alternateSelectedControlTextColor : .labelColor
64 label.lineBreakMode = .byTruncatingTail 52 label.lineBreakMode = .byTruncatingTail
65 stack.addArrangedSubview(label) 53 stack.addArrangedSubview(label)
66 width = max(width, label.intrinsicContentSize.width) 54 width = max(width, label.intrinsicContentSize.width)
@@ -81,56 +69,104 @@ final class CompletionPopup {
81} 69}
82 70
83extension OrgEditor { 71extension OrgEditor {
84 /// `completion-at-point`: one candidate is inserted, several are listed. 72 /// `completion-at-point`: one candidate is inserted, several are listed. Candidates from
73 /// the index join the list when it answers.
85 func completeAtPoint() { 74 func completeAtPoint() {
86 guard let completion = OrgCompletion.at(context()), !completion.candidates.isEmpty else { 75 guard let completion = OrgCompletion.at(context()), !completion.candidates.isEmpty || completion.query != nil else {
87 closeCompletion() 76 closeCompletion()
88 onMessage?("No match") 77 onMessage?("No match")
89 return 78 return
90 } 79 }
91 if completion.candidates.count == 1 { 80 if completion.query == nil, completion.candidates.count == 1 {
92 closeCompletion() 81 closeCompletion()
93 insertCompletion(completion, completion.candidates[0]) 82 insertCompletion(completion, completion.candidates[0])
94 return 83 return
95 } 84 }
96 showCompletion(completion) 85 openCompletion(completion)
97 } 86 }
98 87
99 func showCompletion(_ completion: Completion) { 88 /// Words from the buffers and the index in a list, the first chosen, or with `last` the
100 if let popup = completionPopup { popup.update(completion) } else { completionPopup = CompletionPopup(completion) } 89 /// last (Doom's C-n and C-p in insert state).
90 func completeWord(last: Bool) {
91 guard let completion = Dabbrev.completion(context(), others: otherBuffers()) else {
92 closeCompletion()
93 return fail("No possible abbreviation preceding point")
94 }
95 if completion.candidates.isEmpty, completionSource == nil { return fail("No dynamic expansion for `\(completion.typed)' found") }
96 openCompletion(completion, select: last ? completion.candidates.count - 1 : 0)
97 }
98
99 /// Shows `completion` when it has candidates, and asks the index for more.
100 func openCompletion(_ completion: Completion, select: Int? = nil) {
101 completionFetched = nil
102 if !completion.candidates.isEmpty { showCompletion(completion, select: select) }
103 guard let query = completion.query, let source = completionSource else {
104 if completion.candidates.isEmpty { closeCompletion() }
105 return
106 }
107 let start = completion.range.lowerBound, kind = completion.kind
108 completionTask?.cancel()
109 completionTask = Task { [weak self] in
110 let result = await source(query)
111 guard !Task.isCancelled, let self else { return }
112 self.completionFetched = (kind, start, result)
113 self.fetchedCompletion(kind: kind, start: start, select: select)
114 }
115 }
116
117 /// The index answered: the list shows what it adds, or opens with it.
118 private func fetchedCompletion(kind: Completion.Kind, start: Int, select: Int?) {
119 guard textView.selectedRange().length == 0 else { return }
120 let open = completionPopup?.completion
121 guard open == nil || (open?.kind == kind && open?.range.lowerBound == start) else { return }
122 let words = kind == .word
123 guard let current = CompletionFlow.current(context(), open: nil, words: words, others: otherBuffers, fetched: completionFetched),
124 current.kind == kind, current.range.lowerBound == start, !current.candidates.isEmpty else { return }
125 showCompletion(current, select: open == nil ? select.map { $0 < 0 || $0 >= current.candidates.count ? current.candidates.count - 1 : $0 } : nil)
126 }
127
128 func showCompletion(_ completion: Completion, select: Int? = nil) {
129 if let popup = completionPopup { popup.update(completion) } else { completionPopup = CompletionPopup(completion, selection: select) }
101 let screen = textView.firstRect(forCharacterRange: NSRange(location: completion.range.lowerBound, length: 0), actualRange: nil) 130 let screen = textView.firstRect(forCharacterRange: NSRange(location: completion.range.lowerBound, length: 0), actualRange: nil)
102 completionPopup?.show(under: screen, in: textView.window, font: theme.font) 131 completionPopup?.show(under: screen, in: textView.window, font: theme.font)
103 } 132 }
104 133
105 func closeCompletion() { 134 func closeCompletion() {
106 completionTimer?.cancel() 135 completionTimer?.cancel()
136 completionTask?.cancel()
107 completionPopup?.close() 137 completionPopup?.close()
108 completionPopup = nil 138 completionPopup = nil
109 } 139 }
110 140
111 /// After typing: the open list follows the text; otherwise, with `modal` (corfu-auto), a 141 /// After typing: the open list follows the text; otherwise, as the completion settings
112 /// list opens after a pause once two characters are typed. 142 /// say, a list opens after a pause once enough is typed (corfu-auto).
113 func textTyped() { 143 func textTyped() {
114 completionTimer?.cancel() 144 completionTimer?.cancel()
115 if completionPopup != nil { 145 if completionPopup != nil {
116 refreshCompletion() 146 refreshCompletion()
117 return 147 return
118 } 148 }
119 guard modal, vim.mode == .insert, isOrg else { return } 149 guard let delay = CompletionAuto.delay(options.completion, modal: modal, insertState: vim.mode == .insert, isOrg: isOrg) else { return }
120 let work = DispatchWorkItem { [weak self] in self?.autoComplete() } 150 let work = DispatchWorkItem { [weak self] in self?.autoComplete() }
121 completionTimer = work 151 completionTimer = work
122 DispatchQueue.main.asyncAfter(deadline: .now() + 0.4, execute: work) 152 DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: work)
123 } 153 }
124 154
125 func autoComplete() { 155 func autoComplete() {
126 guard completionPopup == nil, textView.selectedRange().length == 0, 156 guard completionPopup == nil, textView.selectedRange().length == 0 else { return }
127 let completion = OrgCompletion.at(context()), completion.range.count >= 2, !completion.candidates.isEmpty else { return } 157 let context = context()
128 showCompletion(completion) 158 var completion = isOrg ? OrgCompletion.at(context) : nil
159 if options.completion.words, completion.map({ $0.candidates.isEmpty && $0.query == nil }) ?? true {
160 completion = Dabbrev.completion(context, others: otherBuffers())
161 }
162 guard CompletionAuto.opens(completion, options.completion), let completion else { return }
163 openCompletion(completion)
129 } 164 }
130 165
131 func refreshCompletion() { 166 func refreshCompletion() {
132 guard let popup = completionPopup else { return } 167 guard let popup = completionPopup else { return }
133 guard textView.selectedRange().length == 0, let completion = OrgCompletion.at(context()), 168 guard textView.selectedRange().length == 0,
169 let completion = CompletionFlow.current(context(), open: popup.completion, words: false, others: otherBuffers, fetched: completionFetched),
134 completion.range.lowerBound == popup.completion.range.lowerBound, !completion.candidates.isEmpty else { 170 completion.range.lowerBound == popup.completion.range.lowerBound, !completion.candidates.isEmpty else {
135 closeCompletion() 171 closeCompletion()
136 return 172 return
@@ -139,7 +175,9 @@ extension OrgEditor {
139 } 175 }
140 176
141 func insertCompletion(_ completion: Completion, _ candidate: String) { 177 func insertCompletion(_ completion: Completion, _ candidate: String) {
178 defer { completionTimer?.cancel() }
142 if completion.kind == .snippet { return expandCompleted(completion, candidate) } 179 if completion.kind == .snippet { return expandCompleted(completion, candidate) }
180 if completion.kind == .idLink || completion.kind == .denoteLink { return insertLink(completion, candidate) }
143 let (text, caret) = completion.insertion(candidate) 181 let (text, caret) = completion.insertion(candidate)
144 let range = NSRange(location: completion.range.lowerBound, length: completion.range.count) 182 let range = NSRange(location: completion.range.lowerBound, length: completion.range.count)
145 guard textView.shouldChangeText(in: range, replacementString: text) else { return } 183 guard textView.shouldChangeText(in: range, replacementString: text) else { return }
@@ -148,47 +186,89 @@ extension OrgEditor {
148 setCaret(completion.range.lowerBound + caret) 186 setCaret(completion.range.lowerBound + caret)
149 } 187 }
150 188
189 /// A link to the chosen heading or note, its title the description. A heading without an
190 /// ID gets one first, here or in its file, as `org-id-get-create` would.
191 func insertLink(_ completion: Completion, _ candidate: String) {
192 guard let item = completion.item(candidate) else { return }
193 var created: [TextEdit] = []
194 var id = item.id
195 if id == nil, completion.kind == .idLink {
196 if item.path == (options.filePath ?? "") {
197 let newID = UUID().uuidString.lowercased()
198 if let edits = CompletionFlow.createID(item, in: context(), newID: newID) {
199 applyEdits(edits)
200 created = edits
201 id = newID
202 }
203 } else {
204 id = createID?(item)
205 }
206 }
207 guard let id else { return fail("Can't give \(item.title) an ID") }
208 let edit = CompletionFlow.linkEdit(completion, item, id: id, after: created)
209 let range = NSRange(edit.range)
210 guard textView.shouldChangeText(in: range, replacementString: edit.replacement) else { return }
211 textView.textStorage?.replaceCharacters(in: range, with: edit.replacement)
212 textView.didChangeText()
213 setCaret(edit.range.lowerBound + edit.replacement.utf16.count)
214 }
215
216 /// `dabbrev-expand`: the word before the caret completed from the buffers, then the
217 /// index; again right after, the next expansion in its place.
218 func dabbrevExpand() {
219 closeCompletion()
220 let caret = textView.selectedRange().location
221 let repeated = lastCommand?.id == "editor.dabbrev-expand" && lastCommand?.revision == document.revision && dabbrev?.end == caret
222 if !repeated {
223 guard let expansion = DabbrevExpansion(context(), others: otherBuffers()) else { return fail("No possible abbreviation preceding point") }
224 dabbrev = expansion
225 if let source = completionSource {
226 let abbrev = expansion.abbrev, start = expansion.start
227 completionTask = Task { [weak self] in
228 let result = await source(.words(abbrev))
229 guard !Task.isCancelled, let self, self.dabbrev?.start == start else { return }
230 self.dabbrev?.add(result.strings)
231 }
232 }
233 }
234 guard var expansion = dabbrev else { return }
235 let (edit, exhausted) = expansion.advance()
236 dabbrev = expansion
237 let range = NSRange(edit.range)
238 if (document.text as NSString).substring(with: range) != edit.replacement, textView.shouldChangeText(in: range, replacementString: edit.replacement) {
239 textView.textStorage?.replaceCharacters(in: range, with: edit.replacement)
240 textView.didChangeText()
241 }
242 setCaret(expansion.end)
243 completionTimer?.cancel()
244 if exhausted { fail(expansion.failure) }
245 }
246
151 /// Keys while the list is open. Nil lets the key through. 247 /// Keys while the list is open. Nil lets the key through.
152 func completionKey(_ chord: KeyChord) -> Bool? { 248 func completionKey(_ chord: KeyChord) -> Bool? {
153 guard let popup = completionPopup else { return nil } 249 guard let popup = completionPopup else { return nil }
154 let completion = popup.completion 250 let completion = popup.completion
155 switch chord { 251 switch popup.key(chord) {
156 case KeyChord("n", .control), KeyChord("<down>"), KeyChord("j", .control): 252 case .shown:
157 popup.move(1) 253 showCompletion(popup.completion)
158 case KeyChord("p", .control), KeyChord("<up>"), KeyChord("k", .control):
159 popup.move(-1)
160 case KeyChord("TAB"):
161 // corfu-complete: the selection, else the candidates' common start.
162 if let selected = popup.selected {
163 closeCompletion()
164 insertCompletion(completion, selected)
165 } else if completion.candidates.count == 1 {
166 closeCompletion()
167 insertCompletion(completion, completion.candidates[0])
168 } else {
169 let common = completion.candidates.dropFirst().reduce(completion.candidates[0]) { $0.commonPrefix(with: $1) }
170 if common.utf16.count > completion.range.count, completion.kind != .template, completion.kind != .snippet {
171 insertCompletion(completion, common)
172 refreshCompletion()
173 }
174 }
175 return true 254 return true
176 case KeyChord("RET"): 255 case .insert(let candidate):
177 guard let selected = popup.selected else {
178 closeCompletion()
179 return nil
180 }
181 closeCompletion() 256 closeCompletion()
182 insertCompletion(completion, selected) 257 insertCompletion(completion, candidate)
183 return true 258 return true
184 case KeyChord("ESC"), KeyChord("g", .control): 259 case .common(let common):
260 insertCompletion(completion, common)
261 refreshCompletion()
262 return true
263 case .close:
185 closeCompletion() 264 closeCompletion()
186 return chord == KeyChord("ESC") ? nil : true 265 return true
187 default: 266 case .closeAndPass:
267 closeCompletion()
268 return nil
269 case .pass:
188 return nil 270 return nil
189 } 271 }
190 showCompletion(popup.completion)
191 return true
192 } 272 }
193} 273}
194#endif 274#endif
Sources/OrgEditorAppKit/OrgEditor.swift +15 −1 · view
@@ -87,6 +87,11 @@ public final class OrgEditor: NSObject {
87 /// The open completion list, and the pause before one opens by itself. 87 /// The open completion list, and the pause before one opens by itself.
88 var completionPopup: CompletionPopup? 88 var completionPopup: CompletionPopup?
89 var completionTimer: DispatchWorkItem? 89 var completionTimer: DispatchWorkItem?
90 /// The index's answer for the completion starting at `start`, and the query running.
91 var completionFetched: (kind: Completion.Kind, start: Int, result: CompletionResult)?
92 var completionTask: Task<Void, Never>?
93 /// `dabbrev-expand` being repeated.
94 var dabbrev: DabbrevExpansion?
90 /// The snippet whose fields are being filled in, and the range drawn for it last. 95 /// The snippet whose fields are being filled in, and the range drawn for it last.
91 var snippetSession: SnippetSession? 96 var snippetSession: SnippetSession?
92 var snippetHighlight: Range<Int>? 97 var snippetHighlight: Range<Int>?
@@ -385,6 +390,12 @@ public final class OrgEditor: NSObject {
385 public var onExternal: ((ExternalRequest) -> Void)? 390 public var onExternal: ((ExternalRequest) -> Void)?
386 /// Tags used across the workspace, for tag completion. 391 /// Tags used across the workspace, for tag completion.
387 public var knownTags: @Sendable () -> [String] = { [] } 392 public var knownTags: @Sendable () -> [String] = { [] }
393 /// Answers completion's questions to the index; run off the main actor.
394 public var completionSource: (@Sendable (CompletionQuery) async -> CompletionResult)?
395 /// Gives a heading in another file an ID for a link to it; nil when it can't.
396 public var createID: ((CompletionItem) -> String?)?
397 /// The text of the other open buffers, most recent first, for word completion.
398 public var otherBuffers: () -> [String] = { [] }
388 /// Effects other than messages, for the app to carry out. 399 /// Effects other than messages, for the app to carry out.
389 public var onEffect: ((Effect) -> Void)? 400 public var onEffect: ((Effect) -> Void)?
390 /// Where paste looks for images and files; scripts checking the app set another. 401 /// Where paste looks for images and files; scripts checking the app set another.
@@ -597,7 +608,7 @@ public final class OrgEditor: NSObject {
597 } 608 }
598 609
599 /// The last command run and the revision it left, for `last-command`. 610 /// The last command run and the revision it left, for `last-command`.
600 private var lastCommand: (id: String, revision: Int)? 611 var lastCommand: (id: String, revision: Int)?
601 612
602 /// Runs a command by id, as a key, a menu item or the palette would. 613 /// Runs a command by id, as a key, a menu item or the palette would.
603 public func run(_ id: String) { 614 public func run(_ id: String) {
@@ -634,6 +645,9 @@ public final class OrgEditor: NSObject {
634 case "org.latex-preview": toggleLatex() 645 case "org.latex-preview": toggleLatex()
635 case "editor.toggle-spell-check": toggleSpellCheck() 646 case "editor.toggle-spell-check": toggleSpellCheck()
636 case "editor.complete": completeAtPoint() 647 case "editor.complete": completeAtPoint()
648 case "editor.dabbrev-expand": dabbrevExpand()
649 case "editor.dabbrev-completion": completeWord(last: false)
650 case "editor.dabbrev-completion-previous": completeWord(last: true)
637 case "org.snippet.next-field": nextSnippetField() 651 case "org.snippet.next-field": nextSnippetField()
638 case "org.snippet.previous-field": previousSnippetField() 652 case "org.snippet.previous-field": previousSnippetField()
639 case "editor.toggle-truncate-lines": toggleTruncateLines() 653 case "editor.toggle-truncate-lines": toggleTruncateLines()
Sources/Orgstar/OrgstarApp.swift +33 · view
@@ -2,6 +2,7 @@ import AppKit
2import OrgApp 2import OrgApp
3import OrgCore 3import OrgCore
4import OrgEditorAppKit 4import OrgEditorAppKit
5import OrgIndex
5import OrgMathJax 6import OrgMathJax
6import OrgPresentation 7import OrgPresentation
7#if !APPSTORE 8#if !APPSTORE
@@ -51,6 +52,8 @@ final class AppCommands {
51 #endif 52 #endif
52 /// Tags used across the workspace, for tag completion; the main window sets it. 53 /// Tags used across the workspace, for tag completion; the main window sets it.
53 var knownTags: () -> [String] = { [] } 54 var knownTags: () -> [String] = { [] }
55 /// The index completion asks for headings, values and words; the main window sets it.
56 var completionIndex: IndexStore?
54 /// The pending key prefix, and what can follow it. 57 /// The pending key prefix, and what can follow it.
55 var pendingKeys: String? 58 var pendingKeys: String?
56 /// The editor's evil state in the Doom preset. 59 /// The editor's evil state in the Doom preset.
@@ -809,6 +812,11 @@ struct SettingsView: View {
809 @AppStorage("logIntoDrawer") private var logIntoDrawer = "" 812 @AppStorage("logIntoDrawer") private var logIntoDrawer = ""
810 @AppStorage("useSpeedCommands") private var useSpeedCommands = false 813 @AppStorage("useSpeedCommands") private var useSpeedCommands = false
811 @AppStorage("spellCheck") private var spellCheck = false 814 @AppStorage("spellCheck") private var spellCheck = false
815 @AppStorage("completionAuto") private var completionAuto = "preset"
816 @AppStorage("completionAutoDelay") private var completionAutoDelay = 400
817 @AppStorage("completionAutoPrefix") private var completionAutoPrefix = 2
818 @AppStorage("completionStyle") private var completionStyle = "preset"
819 @AppStorage("completionWords") private var completionWords = false
812 @AppStorage("enforceTodoDependencies") private var enforceTodoDependencies = false 820 @AppStorage("enforceTodoDependencies") private var enforceTodoDependencies = false
813 @AppStorage("enforceTodoCheckboxDependencies") private var enforceTodoCheckboxDependencies = false 821 @AppStorage("enforceTodoCheckboxDependencies") private var enforceTodoCheckboxDependencies = false
814 @AppStorage("agendaSpan") private var agendaSpan = 10 822 @AppStorage("agendaSpan") private var agendaSpan = 10
@@ -1031,6 +1039,31 @@ struct SettingsView: View {
1031 Text("Spell checking applies to files as they open; Check Spelling While Typing switches the current file. Code, links, dates, tags and keywords aren't checked.") 1039 Text("Spell checking applies to files as they open; Check Spelling While Typing switches the current file. Code, links, dates, tags and keywords aren't checked.")
1032 .settingsFooter() 1040 .settingsFooter()
1033 } 1041 }
1042 Section {
1043 Picker("Completion list opens", selection: $completionAuto) {
1044 Text("As the keys do (by itself with Doom)").tag("preset")
1045 Text("By itself as you type").tag("on")
1046 Text("Only with a key").tag("off")
1047 }
1048 .help(Text(verbatim: "completion-auto"))
1049 Stepper("After a pause of \(completionAutoDelay) ms", value: $completionAutoDelay, in: 0...2000, step: 50)
1050 .help(Text(verbatim: "completion-auto-delay"))
1051 Stepper("Once \(completionAutoPrefix) characters are typed", value: $completionAutoPrefix, in: 1...10)
1052 .help(Text(verbatim: "completion-auto-prefix"))
1053 Picker("Candidates", selection: $completionStyle) {
1054 Text("As the keys do (letters in order with Doom)").tag("preset")
1055 Text("Start with what's typed").tag("prefix")
1056 Text("Have its letters in order, best first").tag("fuzzy")
1057 }
1058 .help(Text(verbatim: "completion-style"))
1059 Toggle("The list offers words from open files and folders", isOn: $completionWords)
1060 .help(Text(verbatim: "completion-words"))
1061 } header: {
1062 Text("Completion")
1063 } footer: {
1064 Text("Doom's keys open the list by itself and match letters in order, as Doom's corfu does; the Emacs and Mac keys do neither unless set here. Expand Word completes the word before the caret from your files whatever is set.")
1065 .settingsFooter()
1066 }
1034 } 1067 }
1035 .formStyle(.grouped) 1068 .formStyle(.grouped)
1036 .frame(height: 860) 1069 .frame(height: 860)
Sources/OrgstarMobile/MobileEditor+Completion.swift added +280 · view
@@ -0,0 +1,280 @@
1#if os(iOS)
2import OrgApp
3import OrgCore
4import UIKit
5
6/// The completion list under the caret, as on the Mac: keys on a hardware keyboard pick a
7/// row, and a tap inserts one.
8final class CompletionListView: UIView {
9 static let rows = 8
10 private(set) var list: CompletionList
11 private let stack = UIStackView()
12 var onChoose: ((String) -> Void)?
13
14 init(_ completion: Completion, selection: Int?) {
15 list = CompletionList(completion, selection: selection)
16 super.init(frame: .zero)
17 backgroundColor = .secondarySystemBackground
18 layer.borderColor = UIColor.separator.cgColor
19 layer.borderWidth = 1
20 layer.cornerRadius = 6
21 layer.shadowOpacity = 0.15
22 layer.shadowRadius = 6
23 stack.axis = .vertical
24 stack.alignment = .fill
25 addSubview(stack)
26 accessibilityIdentifier = "completion"
27 }
28
29 required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
30
31 var completion: Completion { list.completion }
32
33 func update(_ completion: Completion) { list.update(completion) }
34
35 func key(_ chord: KeyChord) -> CompletionList.Action { list.key(chord) }
36
37 /// Lays the rows out with their top left at `point`, kept inside `bounds`.
38 func show(at point: CGPoint, within bounds: CGRect, font: UIFont) {
39 stack.arrangedSubviews.forEach { $0.removeFromSuperview() }
40 var width: CGFloat = 80
41 for index in list.visible(rows: Self.rows) {
42 let candidate = completion.candidates[index]
43 let label = UILabel()
44 label.text = " " + completion.label(candidate) + (completion.kind == .snippet ? " " + String(localized: "snippet", comment: "Marks a snippet in the completion list") : "") + " "
45 label.font = font
46 label.lineBreakMode = .byTruncatingTail
47 label.isUserInteractionEnabled = true
48 label.backgroundColor = index == list.selection ? .tintColor : .clear
49 label.textColor = index == list.selection ? .white : .label
50 label.tag = index
51 label.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapped(_:))))
52 label.heightAnchor.constraint(equalToConstant: max(28, font.lineHeight + 6)).isActive = true
53 stack.addArrangedSubview(label)
54 width = max(width, label.intrinsicContentSize.width)
55 }
56 width = min(width, bounds.width - 16)
57 let height = stack.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height
58 let x = min(max(bounds.minX + 8, point.x), bounds.maxX - width - 8)
59 frame = CGRect(x: x, y: point.y + 2, width: width, height: height)
60 stack.frame = CGRect(origin: .zero, size: frame.size)
61 }
62
63 @objc private func tapped(_ gesture: UITapGestureRecognizer) {
64 guard let index = gesture.view?.tag, completion.candidates.indices.contains(index) else { return }
65 onChoose?(completion.candidates[index])
66 }
67}
68
69extension MobileEditor {
70 /// Org files complete Org's positions; other files only words.
71 var completesOrg: Bool { fileName.map(DocumentSession.isOrgPath) ?? true }
72
73 /// `completion-at-point`: one candidate is inserted, several are listed.
74 func completeAtPoint() {
75 guard completesOrg, let completion = OrgCompletion.at(editContext()), !completion.candidates.isEmpty || completion.query != nil else {
76 closeCompletion()
77 onMessage?("No match")
78 return
79 }
80 if completion.query == nil, completion.candidates.count == 1 {
81 closeCompletion()
82 insertCompletion(completion, completion.candidates[0])
83 return
84 }
85 openCompletion(completion)
86 }
87
88 /// Words in a list, the first chosen, or with `last` the last.
89 func completeWord(last: Bool) {
90 guard let completion = Dabbrev.completion(editContext(), others: otherBuffers()) else {
91 closeCompletion()
92 return fail("No possible abbreviation preceding point")
93 }
94 if completion.candidates.isEmpty, completionSource == nil { return fail("No dynamic expansion for `\(completion.typed)' found") }
95 openCompletion(completion, select: last ? completion.candidates.count - 1 : 0)
96 }
97
98 func openCompletion(_ completion: Completion, select: Int? = nil) {
99 completionFetched = nil
100 if !completion.candidates.isEmpty { showCompletion(completion, select: select) }
101 guard let query = completion.query, let source = completionSource else {
102 if completion.candidates.isEmpty { closeCompletion() }
103 return
104 }
105 let start = completion.range.lowerBound, kind = completion.kind
106 completionTask?.cancel()
107 completionTask = Task { [weak self] in
108 let result = await source(query)
109 guard !Task.isCancelled, let self else { return }
110 self.completionFetched = (kind, start, result)
111 self.fetchedCompletion(kind: kind, start: start, select: select)
112 }
113 }
114
115 private func fetchedCompletion(kind: Completion.Kind, start: Int, select: Int?) {
116 guard textView.selectedRange.length == 0 else { return }
117 let open = completionList?.completion
118 guard open == nil || (open?.kind == kind && open?.range.lowerBound == start) else { return }
119 guard let current = CompletionFlow.current(editContext(), open: nil, words: kind == .word, others: otherBuffers, fetched: completionFetched),
120 current.kind == kind, current.range.lowerBound == start, !current.candidates.isEmpty else { return }
121 showCompletion(current, select: open == nil ? select.map { $0 < 0 || $0 >= current.candidates.count ? current.candidates.count - 1 : $0 } : nil)
122 }
123
124 func showCompletion(_ completion: Completion, select: Int? = nil) {
125 let view: CompletionListView
126 if let open = completionList {
127 open.update(completion)
128 view = open
129 } else {
130 view = CompletionListView(completion, selection: select)
131 view.onChoose = { [weak self, weak view] candidate in
132 guard let self, let view else { return }
133 let completion = view.completion
134 self.closeCompletion()
135 self.insertCompletion(completion, candidate)
136 }
137 completionList = view
138 textView.addSubview(view)
139 }
140 guard let position = textView.position(from: textView.beginningOfDocument, offset: completion.range.lowerBound) else { return }
141 let caret = textView.caretRect(for: position)
142 let visible = CGRect(origin: textView.contentOffset, size: textView.bounds.size)
143 view.show(at: CGPoint(x: caret.minX, y: caret.maxY), within: visible, font: theme.font)
144 }
145
146 func closeCompletion() {
147 completionTimer?.invalidate()
148 completionTimer = nil
149 completionTask?.cancel()
150 completionList?.removeFromSuperview()
151 completionList = nil
152 }
153
154 /// After typing: the open list follows the text; otherwise, as the settings say, a list
155 /// opens after a pause once enough is typed.
156 func textTyped() {
157 completionTimer?.invalidate()
158 completionTimer = nil
159 if completionList != nil { return refreshCompletion() }
160 guard let delay = CompletionAuto.delay(options.completion, modal: modal, insertState: vim.mode == .insert, isOrg: completesOrg) else { return }
161 completionTimer = Timer.scheduledTimer(withTimeInterval: delay, repeats: false) { [weak self] _ in
162 MainActor.assumeIsolated { self?.autoComplete() }
163 }
164 }
165
166 func autoComplete() {
167 guard completionList == nil, textView.selectedRange.length == 0, textView.markedTextRange == nil else { return }
168 let context = editContext()
169 var completion = completesOrg ? OrgCompletion.at(context) : nil
170 if options.completion.words, completion.map({ $0.candidates.isEmpty && $0.query == nil }) ?? true {
171 completion = Dabbrev.completion(context, others: otherBuffers())
172 }
173 guard CompletionAuto.opens(completion, options.completion), let completion else { return }
174 openCompletion(completion)
175 }
176
177 func refreshCompletion() {
178 guard let open = completionList else { return }
179 guard textView.selectedRange.length == 0,
180 let completion = CompletionFlow.current(editContext(), open: open.completion, words: false, others: otherBuffers, fetched: completionFetched),
181 completion.range.lowerBound == open.completion.range.lowerBound, !completion.candidates.isEmpty else {
182 closeCompletion()
183 return
184 }
185 showCompletion(completion)
186 }
187
188 func insertCompletion(_ completion: Completion, _ candidate: String) {
189 defer {
190 completionTimer?.invalidate()
191 completionTimer = nil
192 }
193 if completion.kind == .snippet {
194 textView.selectedRange = NSRange(location: completion.range.lowerBound, length: completion.range.count)
195 _ = perform(ExpandNamedSnippet(trigger: candidate))
196 return
197 }
198 if completion.kind == .idLink || completion.kind == .denoteLink { return insertLink(completion, candidate) }
199 let (text, caret) = completion.insertion(candidate)
200 applyEdits([TextEdit(range: completion.range, replacement: text)])
201 textView.selectedRange = NSRange(location: completion.range.lowerBound + caret, length: 0)
202 }
203
204 /// A link to the chosen heading or note, with an ID given to a heading without one.
205 func insertLink(_ completion: Completion, _ candidate: String) {
206 guard let item = completion.item(candidate) else { return }
207 var created: [TextEdit] = []
208 var id = item.id
209 if id == nil, completion.kind == .idLink {
210 if item.path == (options.filePath ?? "") {
211 let newID = UUID().uuidString.lowercased()
212 if let edits = CompletionFlow.createID(item, in: editContext(), newID: newID) {
213 applyEdits(edits)
214 created = edits
215 id = newID
216 }
217 } else {
218 id = createID?(item)
219 }
220 }
221 guard let id else { return fail("Can't give \(item.title) an ID") }
222 let edit = CompletionFlow.linkEdit(completion, item, id: id, after: created)
223 applyEdits([edit])
224 textView.selectedRange = NSRange(location: edit.range.lowerBound + edit.replacement.utf16.count, length: 0)
225 }
226
227 /// `dabbrev-expand`, repeated right after for the next expansion.
228 func dabbrevExpand() {
229 closeCompletion()
230 let caret = textView.selectedRange.location
231 let repeated = dabbrevRevision == document.revision && dabbrev?.end == caret
232 if !repeated {
233 guard let expansion = DabbrevExpansion(editContext(), others: otherBuffers()) else { return fail("No possible abbreviation preceding point") }
234 dabbrev = expansion
235 if let source = completionSource {
236 let abbrev = expansion.abbrev, start = expansion.start
237 completionTask = Task { [weak self] in
238 let result = await source(.words(abbrev))
239 guard !Task.isCancelled, let self, self.dabbrev?.start == start else { return }
240 self.dabbrev?.add(result.strings)
241 }
242 }
243 }
244 guard var expansion = dabbrev else { return }
245 let (edit, exhausted) = expansion.advance()
246 dabbrev = expansion
247 if (document.text as NSString).substring(with: NSRange(edit.range)) != edit.replacement { applyEdits([edit]) }
248 textView.selectedRange = NSRange(location: expansion.end, length: 0)
249 dabbrevRevision = document.revision
250 if exhausted { fail(expansion.failure) }
251 }
252
253 /// Keys while the list is open; nil lets the key through.
254 func completionKey(_ chord: KeyChord) -> Bool? {
255 guard let open = completionList else { return nil }
256 let completion = open.completion
257 switch open.key(chord) {
258 case .shown:
259 showCompletion(open.completion)
260 return true
261 case .insert(let candidate):
262 closeCompletion()
263 insertCompletion(completion, candidate)
264 return true
265 case .common(let common):
266 insertCompletion(completion, common)
267 refreshCompletion()
268 return true
269 case .close:
270 closeCompletion()
271 return true
272 case .closeAndPass:
273 closeCompletion()
274 return nil
275 case .pass:
276 return nil
277 }
278 }
279}
280#endif
Sources/OrgstarMobile/MobileEditor+Snippets.swift +1 · view
@@ -135,6 +135,7 @@ extension MobileEditor {
135 func textViewDidChange(_ textView: UITextView) { 135 func textViewDidChange(_ textView: UITextView) {
136 guard textView === self.textView else { return } 136 guard textView === self.textView else { return }
137 updateSnippetMirrors() 137 updateSnippetMirrors()
138 textTyped()
138 } 139 }
139} 140}
140#endif 141#endif
Sources/OrgstarMobile/MobileEditor.swift +24 −2 · view
@@ -118,6 +118,21 @@ final class MobileEditor: NSObject, DocumentBuffer {
118 var onImage: ((Data, String) -> Void)? 118 var onImage: ((Data, String) -> Void)?
119 /// Tags used across the workspace, for completion. 119 /// Tags used across the workspace, for completion.
120 var knownTags: @Sendable () -> [String] = { [] } 120 var knownTags: @Sendable () -> [String] = { [] }
121 /// Answers completion's questions to the index, off the main actor.
122 var completionSource: (@Sendable (CompletionQuery) async -> CompletionResult)?
123 /// Gives a heading in another file an ID for a link to it; nil when it can't.
124 var createID: ((CompletionItem) -> String?)?
125 /// The text of the other open buffers, for word completion.
126 var otherBuffers: () -> [String] = { [] }
127 /// The open completion list, the pause before one opens by itself, the index's answer
128 /// and the query running.
129 var completionList: CompletionListView?
130 var completionTimer: Timer?
131 var completionFetched: CompletionFlow.Fetched?
132 var completionTask: Task<Void, Never>?
133 /// `dabbrev-expand` being repeated, and the revision its last expansion left.
134 var dabbrev: DabbrevExpansion?
135 var dabbrevRevision: Int?
121 136
122 var theme: MobileTheme 137 var theme: MobileTheme
123 var fold = FoldState() 138 var fold = FoldState()
@@ -425,6 +440,10 @@ final class MobileEditor: NSObject, DocumentBuffer {
425 } 440 }
426 switch id { 441 switch id {
427 case "org.snippet.next-field": nextSnippetField() 442 case "org.snippet.next-field": nextSnippetField()
443 case "editor.complete": completeAtPoint()
444 case "editor.dabbrev-expand": dabbrevExpand()
445 case "editor.dabbrev-completion": completeWord(last: false)
446 case "editor.dabbrev-completion-previous": completeWord(last: true)
428 case "org.snippet.previous-field": previousSnippetField() 447 case "org.snippet.previous-field": previousSnippetField()
429 case "org.cycle": 448 case "org.cycle":
430 if !cycleAtCaret() { onMessage?("Not on a heading, drawer or block") } 449 if !cycleAtCaret() { onMessage?("Not on a heading, drawer or block") }
@@ -470,7 +489,8 @@ final class MobileEditor: NSObject, DocumentBuffer {
470 return Presentation.heading(containing: context.caret, in: context.tree) != nil || Wrappers.toggleable(at: context.caret, in: context.tree) != nil 489 return Presentation.heading(containing: context.caret, in: context.tree) != nil || Wrappers.toggleable(at: context.caret, in: context.tree) != nil
471 case _ where id.hasPrefix("org.fold."): return true 490 case _ where id.hasPrefix("org.fold."): return true
472 case "org.cycle-global", "edit.undo", "edit.redo", "org.toggle-inline-images", "org.toggle-inline-images-linked", "org.latex-preview", "editor.toggle-truncate-lines", 491 case "org.cycle-global", "edit.undo", "edit.redo", "org.toggle-inline-images", "org.toggle-inline-images-linked", "org.latex-preview", "editor.toggle-truncate-lines",
473 "editor.toggle-auto-fill", "edit.isearch-forward", "edit.isearch-backward", 492 "editor.toggle-auto-fill", "edit.isearch-forward", "edit.isearch-backward", "editor.complete", "editor.dabbrev-expand",
493 "editor.dabbrev-completion", "editor.dabbrev-completion-previous",
474 "edit.isearch-forward-regexp", "edit.isearch-backward-regexp": return true 494 "edit.isearch-forward-regexp", "edit.isearch-backward-regexp": return true
475 case "app.clock.in", "app.clock.out", "app.clock.cancel", "app.clock.goto", "app.clock.in-recent", "app.clock.in-last", 495 case "app.clock.in", "app.clock.out", "app.clock.cancel", "app.clock.goto", "app.clock.in-recent", "app.clock.in-last",
476 "app.clock.goto-recent", "app.clock.default", "app.clock.resolve", "app.toggle-markup": return onAppCommand != nil 496 "app.clock.goto-recent", "app.clock.default", "app.clock.resolve", "app.toggle-markup": return onAppCommand != nil
@@ -504,7 +524,7 @@ final class MobileEditor: NSObject, DocumentBuffer {
504 .keyboardTab: "TAB", .keyboardReturnOrEnter: "RET", .keypadEnter: "RET", .keyboardSpacebar: "SPC", 524 .keyboardTab: "TAB", .keyboardReturnOrEnter: "RET", .keypadEnter: "RET", .keyboardSpacebar: "SPC",
505 .keyboardEscape: "ESC", .keyboardDeleteOrBackspace: "DEL", .keyboardDeleteForward: "<delete>", 525 .keyboardEscape: "ESC", .keyboardDeleteOrBackspace: "DEL", .keyboardDeleteForward: "<delete>",
506 .keyboardLeftArrow: "<left>", .keyboardRightArrow: "<right>", .keyboardUpArrow: "<up>", .keyboardDownArrow: "<down>", 526 .keyboardLeftArrow: "<left>", .keyboardRightArrow: "<right>", .keyboardUpArrow: "<up>", .keyboardDownArrow: "<down>",
507 .keyboardHome: "<home>", .keyboardEnd: "<end>", .keyboardPageUp: "<prior>", .keyboardPageDown: "<next>", 527 .keyboardHome: "<home>", .keyboardEnd: "<end>", .keyboardPageUp: "<prior>", .keyboardPageDown: "<next>", .keyboardF5: "<f5>",
508 ] 528 ]
509 529
510 /// A key press as a chord; Option is Meta, as `option-as-meta` makes it on the Mac. 530 /// A key press as a chord; Option is Meta, as `option-as-meta` makes it on the Mac.
@@ -543,6 +563,7 @@ final class MobileEditor: NSObject, DocumentBuffer {
543 } 563 }
544 } 564 }
545 if isearch != nil, isearchKey(chord) { return true } 565 if isearch != nil, isearchKey(chord) { return true }
566 if let handled = completionKey(chord) { return handled }
546 if let handled = snippetKey(chord) { return handled } 567 if let handled = snippetKey(chord) { return handled }
547 if modal { return handleModal(chord) } 568 if modal { return handleModal(chord) }
548 // Option alone types characters unless it begins a binding. 569 // Option alone types characters unless it begins a binding.
@@ -710,6 +731,7 @@ extension MobileEditor: UITextViewDelegate {
710 if textView.isFirstResponder { focus(textView) } 731 if textView.isFirstResponder { focus(textView) }
711 guard textView === self.textView else { return } 732 guard textView === self.textView else { return }
712 selectionChanged() 733 selectionChanged()
734 if let open = completionList, textView.selectedRange.location != open.completion.range.upperBound { refreshCompletion() }
713 } 735 }
714 736
715 /// `electric-pair-mode` for typed brackets and quotes, DEL and RET, and `auto-fill-mode` 737 /// `electric-pair-mode` for typed brackets and quotes, DEL and RET, and `auto-fill-mode`
Sources/OrgstarMobile/SettingsScreen.swift +37 · view
@@ -120,6 +120,43 @@ struct SettingsScreen: View {
120 } footer: { 120 } footer: {
121 Text("org-enforce-todo-dependencies and org-enforce-todo-checkbox-dependencies.") 121 Text("org-enforce-todo-dependencies and org-enforce-todo-checkbox-dependencies.")
122 } 122 }
123 Section {
124 let _ = model.settingsVersion
125 Picker("Completion list opens", selection: Binding {
126 UserDefaults.standard.string(forKey: "completionAuto") ?? "preset"
127 } set: { model.set("completionAuto", to: .string($0)) }) {
128 Text("As the keys do (by itself with Doom)").tag("preset")
129 Text("By itself as you type").tag("on")
130 Text("Only with a key").tag("off")
131 }
132 .help(Text(verbatim: "completion-auto"))
133 let delay = OrgPreferences.completion().delay
134 Stepper("After a pause of \(Int(delay * 1000)) ms", value: Binding {
135 Int(delay * 1000)
136 } set: { model.set("completionAutoDelay", to: .integer($0)) }, in: 0...2000, step: 50)
137 .help(Text(verbatim: "completion-auto-delay"))
138 let prefix = OrgPreferences.completion().prefix
139 Stepper("Once \(prefix) characters are typed", value: Binding {
140 prefix
141 } set: { model.set("completionAutoPrefix", to: .integer($0)) }, in: 1...10)
142 .help(Text(verbatim: "completion-auto-prefix"))
143 Picker("Candidates", selection: Binding {
144 UserDefaults.standard.string(forKey: "completionStyle") ?? "preset"
145 } set: { model.set("completionStyle", to: .string($0)) }) {
146 Text("As the keys do (letters in order with Doom)").tag("preset")
147 Text("Start with what's typed").tag("prefix")
148 Text("Have its letters in order, best first").tag("fuzzy")
149 }
150 .help(Text(verbatim: "completion-style"))
151 Toggle("The list offers words from open files and folders", isOn: Binding {
152 OrgPreferences.completion().words
153 } set: { model.set("completionWords", to: .bool($0)) })
154 .help(Text(verbatim: "completion-words"))
155 } header: {
156 Text("Completion")
157 } footer: {
158 Text("With a hardware keyboard. Doom's keys open the list by itself and match letters in order, as Doom's corfu does; the Emacs and Mac keys do neither unless set here.")
159 }
123 calendarSection 160 calendarSection
124 reminderSection 161 reminderSection
125 Section { 162 Section {
Tests/OrgEditorAppKitTests/CompletionPopupTests.swift +61 · view
@@ -73,4 +73,65 @@ struct CompletionPopupTests {
73 ModalTests().type(h, "C-SPC") 73 ModalTests().type(h, "C-SPC")
74 #expect(h.editor.document.text.contains("\\alpha")) 74 #expect(h.editor.document.text.contains("\\alpha"))
75 } 75 }
76
77 /// #139: typing schedules the list only when the setting is on.
78 @Test func typingOpensTheListOnlyWhenSet() {
79 let h = at("* H :work:\n* I :wo")
80 h.editor.textTyped()
81 #expect(h.editor.completionTimer == nil)
82 h.editor.options.completion = CompletionOptions(auto: true, delay: 0.01, prefix: 2)
83 h.editor.textTyped()
84 #expect(h.editor.completionTimer != nil)
85 h.editor.completionTimer?.perform()
86 #expect(h.editor.completionPopup?.completion.candidates == ["work:"])
87 }
88
89 /// #140: with fuzzy matching, letters in order, best first.
90 @Test func fuzzyListFollowsTyping() {
91 let h = at("#+STARTUP: lgd")
92 h.editor.options.completion.fuzzy = true
93 h.editor.run("editor.complete")
94 #expect(h.editor.completionPopup?.completion.candidates.first == "logdone")
95 h.textView.insertText("r", replacementRange: h.textView.selectedRange())
96 #expect(h.editor.completionPopup?.completion.candidates == ["logdrawer", "nologdrawer"])
97 }
98
99 /// #141: M-/ expands and cycles; Doom's C-n lists words with the first chosen.
100 @Test func wordsExpandAndList() {
101 let h = at("help hello\nhe")
102 h.editor.keymap = KeymapPreset.emacs.keymap
103 h.editor.otherBuffers = { ["helmet"] }
104 h.editor.run("editor.dabbrev-expand")
105 #expect(h.editor.document.text == "help hello\nhello")
106 h.editor.run("editor.dabbrev-expand")
107 #expect(h.editor.document.text == "help hello\nhelp")
108 h.editor.run("editor.dabbrev-expand")
109 #expect(h.editor.document.text == "help hello\nhelmet")
110 h.editor.run("editor.dabbrev-expand")
111 #expect(h.editor.document.text == "help hello\nhe" && h.caret == 13)
112
113 let doom = Harness("help hello\n\n")
114 doom.editor.keymap = KeymapPreset.doom.keymap
115 doom.editor.modal = true
116 doom.caret(at: 11)
117 ModalTests().type(doom, "a")
118 doom.textView.insertText("he", replacementRange: doom.textView.selectedRange())
119 ModalTests().type(doom, "C-n")
120 #expect(doom.editor.completionPopup?.completion.candidates == ["hello", "help"] && doom.editor.completionPopup?.selected == "hello")
121 ModalTests().type(doom, "C-n RET")
122 #expect(doom.editor.document.text == "help hello\nhelp\n")
123 }
124
125 /// #143: a heading here without an ID gets one, and the link has its title.
126 @Test func idLinkToAHeadingHere() {
127 let h = at("* Plan\nBody\n* Notes\nSee [[id:Pl")
128 h.editor.options.filePath = "/tmp/here.org"
129 h.editor.run("editor.complete")
130 #expect(h.editor.completionPopup?.completion.candidates == ["Plan"])
131 ModalTests().type(h, "TAB")
132 let text = h.editor.document.text
133 let id = try? #require(text.firstMatch(of: /:ID: +(\S+)/)).1
134 #expect(text.hasPrefix("* Plan\n:PROPERTIES:\n:ID:"))
135 #expect(id.map { text.hasSuffix("See [[id:\($0)][Plan]]") } == true && h.caret == text.utf16.count)
136 }
76} 137}
docs/manual/guide/13-configuration.org +12 · view
@@ -89,6 +89,11 @@ Automatic saving writes a file one second after you stop typing. The keymap pres
89| State notes go in a LOGBOOK drawer | On or off | Off | =org-log-into-drawer= | 89| State notes go in a LOGBOOK drawer | On or off | Off | =org-log-into-drawer= |
90| Speed keys | On or off | Off | =org-use-speed-commands= | 90| Speed keys | On or off | Off | =org-use-speed-commands= |
91| Check spelling while typing | On or off | Off | =spell-check= | 91| Check spelling while typing | On or off | Off | =spell-check= |
92| Completion list opens | As the keys do; By itself as you type; Only with a key | As the keys do | =completion-auto= |
93| After a pause of N ms | 0 to 2000, in steps of 50 | 400 | =completion-auto-delay= |
94| Once N characters are typed | 1 to 10 | 2 | =completion-auto-prefix= |
95| Candidates | As the keys do; Start with what's typed; Have its letters in order, best first | As the keys do | =completion-style= |
96| The list offers words from open files and folders | On or off | Off | =completion-words= |
92 97
93The two New headings switches and the fill column show the keys of Insert Heading and Fill Paragraph in the preset you use, and each control's help tag names its =config.toml= key. The two "Emacs hides" and "Emacs shows" switches describe your Emacs, not orgstar's display. Tag alignment, table alignment and Fill Paragraph measure text the way your Emacs displays it, so a file edited in both keeps the same layout. Set them to match your Emacs configuration. They also control whether orgstar hides markers and shows entities when markup is hidden. 98The two New headings switches and the fill column show the keys of Insert Heading and Fill Paragraph in the preset you use, and each control's help tag names its =config.toml= key. The two "Emacs hides" and "Emacs shows" switches describe your Emacs, not orgstar's display. Tag alignment, table alignment and Fill Paragraph measure text the way your Emacs displays it, so a file edited in both keeps the same layout. Set them to match your Emacs configuration. They also control whether orgstar hides markers and shows entities when markup is hidden.
94 99
@@ -100,6 +105,8 @@ Default TODO keywords apply to files without a =#+TODO= line. orgstar reads them
100 105
101The two dependency switches are described under Dependencies in [[file:05-todos-and-tags.org][TODOs and tags]]. 106The two dependency switches are described under Dependencies in [[file:05-todos-and-tags.org][TODOs and tags]].
102 107
108The completion controls are described under Completion in [[file:02-the-editor.org][The editor]]. "As the keys do" follows the Keys preset: the list opens by itself and matches letters in order with Doom, as Doom's corfu does with orderless, and does neither with Emacs or Mac keys. The iOS app has the same controls in Settings ▸ Completion.
109
103The LOGBOOK switch writes =org-log-into-drawer= as ="LOGBOOK"= or =""=. A drawer name of your own in =config.toml= shows the switch on; turning it off and on again replaces the name with =LOGBOOK=. Logging is described under Logging in [[file:05-todos-and-tags.org][TODOs and tags]], speed keys in [[file:03-keys.org][Keys and commands]] and spell checking in [[file:02-the-editor.org][The editor]]. 110The LOGBOOK switch writes =org-log-into-drawer= as ="LOGBOOK"= or =""=. A drawer name of your own in =config.toml= shows the switch on; turning it off and on again replaces the name with =LOGBOOK=. Logging is described under Logging in [[file:05-todos-and-tags.org][TODOs and tags]], speed keys in [[file:03-keys.org][Keys and commands]] and spell checking in [[file:02-the-editor.org][The editor]].
104 111
105** Language 112** Language
@@ -448,6 +455,11 @@ Any other key in =[theme]= is a color; see Themes below.
448| =save= | string | ="automatic"= | =automatic= (one second after typing stops) or =explicit= (only with =⌘S=). | 455| =save= | string | ="automatic"= | =automatic= (one second after typing stops) or =explicit= (only with =⌘S=). |
449| =keymap= | string | ="emacs"= | =emacs=, =mac= or =doom=. Your own bindings go in =keymap.toml=. | 456| =keymap= | string | ="emacs"= | =emacs=, =mac= or =doom=. Your own bindings go in =keymap.toml=. |
450| =option-as-meta= | string | ="left"= | Which Option key is Meta: =left=, =right=, =both= or =none=. | 457| =option-as-meta= | string | ="left"= | Which Option key is Meta: =left=, =right=, =both= or =none=. |
458| =completion-auto= | string | ="preset"= | The completion list opens by itself as you type: =on=, =off=, or =preset= (on with =doom=, off with =emacs= and =mac=) (=corfu-auto=). |
459| =completion-auto-delay= | integer | =400= | Milliseconds after typing stops before it opens (=corfu-auto-delay=, in seconds in Emacs). |
460| =completion-auto-prefix= | integer | =2= | Characters typed before it opens (=corfu-auto-prefix=). |
461| =completion-style= | string | ="preset"= | =prefix=: candidates start with what's typed; =fuzzy=: they have its letters in order, best first; =preset=: =fuzzy= with =doom=, =prefix= with =emacs= and =mac=. |
462| =completion-words= | boolean | =false= | The list that opens by itself offers words from your buffers and folders where Org offers nothing. |
451| =pdf-margin= | integer | =50= | PDF export's page margins, in points. | 463| =pdf-margin= | integer | =50= | PDF export's page margins, in points. |
452| =pdf-font= | string | =""= | A font family for PDF export's text; =""= keeps the export's own. | 464| =pdf-font= | string | =""= | A font family for PDF export's text; =""= keeps the export's own. |
453| =pdf-page-numbers= | boolean | =true= | Number PDF export's pages. | 465| =pdf-page-numbers= | boolean | =true= | Number PDF export's pages. |
l10n/Localizable.xcstrings +581 · view
@@ -3852,6 +3852,40 @@
3852 } 3852 }
3853 } 3853 }
3854 }, 3854 },
3855 "After a pause of %lld ms": {
3856 "localizations": {
3857 "de": {
3858 "stringUnit": {
3859 "state": "translated",
3860 "value": "Nach einer Pause von %lld ms"
3861 }
3862 },
3863 "es": {
3864 "stringUnit": {
3865 "state": "translated",
3866 "value": "Tras una pausa de %lld ms"
3867 }
3868 },
3869 "fr": {
3870 "stringUnit": {
3871 "state": "translated",
3872 "value": "Après une pause de %lld ms"
3873 }
3874 },
3875 "ja": {
3876 "stringUnit": {
3877 "state": "translated",
3878 "value": "%lld ms の休止後"
3879 }
3880 },
3881 "pt-BR": {
3882 "stringUnit": {
3883 "state": "translated",
3884 "value": "Após uma pausa de %lld ms"
3885 }
3886 }
3887 }
3888 },
3855 "Agenda": { 3889 "Agenda": {
3856 "comment": "Command title", 3890 "comment": "Command title",
3857 "localizations": { 3891 "localizations": {
@@ -5254,6 +5288,74 @@
5254 } 5288 }
5255 } 5289 }
5256 }, 5290 },
5291 "As the keys do (by itself with Doom)": {
5292 "localizations": {
5293 "de": {
5294 "stringUnit": {
5295 "state": "translated",
5296 "value": "Wie die Tasten es tun (bei Doom von selbst)"
5297 }
5298 },
5299 "es": {
5300 "stringUnit": {
5301 "state": "translated",
5302 "value": "Como las teclas (sola con Doom)"
5303 }
5304 },
5305 "fr": {
5306 "stringUnit": {
5307 "state": "translated",
5308 "value": "Comme les touches (d'elle-même avec Doom)"
5309 }
5310 },
5311 "ja": {
5312 "stringUnit": {
5313 "state": "translated",
5314 "value": "キー設定に従う(Doomでは自動)"
5315 }
5316 },
5317 "pt-BR": {
5318 "stringUnit": {
5319 "state": "translated",
5320 "value": "Como as teclas fazem (sozinha com Doom)"
5321 }
5322 }
5323 }
5324 },
5325 "As the keys do (letters in order with Doom)": {
5326 "localizations": {
5327 "de": {
5328 "stringUnit": {
5329 "state": "translated",
5330 "value": "Wie die Tasten es tun (bei Doom Buchstaben in Reihenfolge)"
5331 }
5332 },
5333 "es": {
5334 "stringUnit": {
5335 "state": "translated",
5336 "value": "Como las teclas (letras en orden con Doom)"
5337 }
5338 },
5339 "fr": {
5340 "stringUnit": {
5341 "state": "translated",
5342 "value": "Comme les touches (lettres dans l'ordre avec Doom)"
5343 }
5344 },
5345 "ja": {
5346 "stringUnit": {
5347 "state": "translated",
5348 "value": "キー設定に従う(Doomでは文字の順序で一致)"
5349 }
5350 },
5351 "pt-BR": {
5352 "stringUnit": {
5353 "state": "translated",
5354 "value": "Como as teclas fazem (letras em ordem com Doom)"
5355 }
5356 }
5357 }
5358 },
5257 "Ask what to do with idle time while clocked in": { 5359 "Ask what to do with idle time while clocked in": {
5258 "localizations": { 5360 "localizations": {
5259 "de": { 5361 "de": {
@@ -6598,6 +6700,40 @@
6598 } 6700 }
6599 } 6701 }
6600 }, 6702 },
6703 "By itself as you type": {
6704 "localizations": {
6705 "de": {
6706 "stringUnit": {
6707 "state": "translated",
6708 "value": "Von selbst beim Tippen"
6709 }
6710 },
6711 "es": {
6712 "stringUnit": {
6713 "state": "translated",
6714 "value": "Sola al escribir"
6715 }
6716 },
6717 "fr": {
6718 "stringUnit": {
6719 "state": "translated",
6720 "value": "D'elle-même pendant la frappe"
6721 }
6722 },
6723 "ja": {
6724 "stringUnit": {
6725 "state": "translated",
6726 "value": "入力中に自動で"
6727 }
6728 },
6729 "pt-BR": {
6730 "stringUnit": {
6731 "state": "translated",
6732 "value": "Sozinha ao digitar"
6733 }
6734 }
6735 }
6736 },
6601 "C-c ' or ⌘Return saves, Escape or C-c C-k leaves": { 6737 "C-c ' or ⌘Return saves, Escape or C-c C-k leaves": {
6602 "localizations": { 6738 "localizations": {
6603 "de": { 6739 "de": {
@@ -7220,6 +7356,40 @@
7220 } 7356 }
7221 } 7357 }
7222 }, 7358 },
7359 "Candidates": {
7360 "localizations": {
7361 "de": {
7362 "stringUnit": {
7363 "state": "translated",
7364 "value": "Kandidaten"
7365 }
7366 },
7367 "es": {
7368 "stringUnit": {
7369 "state": "translated",
7370 "value": "Candidatos"
7371 }
7372 },
7373 "fr": {
7374 "stringUnit": {
7375 "state": "translated",
7376 "value": "Candidats"
7377 }
7378 },
7379 "ja": {
7380 "stringUnit": {
7381 "state": "translated",
7382 "value": "候補"
7383 }
7384 },
7385 "pt-BR": {
7386 "stringUnit": {
7387 "state": "translated",
7388 "value": "Candidatos"
7389 }
7390 }
7391 }
7392 },
7223 "Capture": { 7393 "Capture": {
7224 "localizations": { 7394 "localizations": {
7225 "de": { 7395 "de": {
@@ -10047,6 +10217,76 @@
10047 } 10217 }
10048 } 10218 }
10049 }, 10219 },
10220 "Complete Word": {
10221 "comment": "Command title",
10222 "localizations": {
10223 "de": {
10224 "stringUnit": {
10225 "state": "translated",
10226 "value": "Wort vervollständigen"
10227 }
10228 },
10229 "es": {
10230 "stringUnit": {
10231 "state": "translated",
10232 "value": "Completar palabra"
10233 }
10234 },
10235 "fr": {
10236 "stringUnit": {
10237 "state": "translated",
10238 "value": "Compléter le mot"
10239 }
10240 },
10241 "ja": {
10242 "stringUnit": {
10243 "state": "translated",
10244 "value": "単語を補完"
10245 }
10246 },
10247 "pt-BR": {
10248 "stringUnit": {
10249 "state": "translated",
10250 "value": "Completar Palavra"
10251 }
10252 }
10253 }
10254 },
10255 "Complete Word, Last First": {
10256 "comment": "Command title",
10257 "localizations": {
10258 "de": {
10259 "stringUnit": {
10260 "state": "translated",
10261 "value": "Wort vervollständigen, letztes zuerst"
10262 }
10263 },
10264 "es": {
10265 "stringUnit": {
10266 "state": "translated",
10267 "value": "Completar palabra, la última primero"
10268 }
10269 },
10270 "fr": {
10271 "stringUnit": {
10272 "state": "translated",
10273 "value": "Compléter le mot, le dernier d'abord"
10274 }
10275 },
10276 "ja": {
10277 "stringUnit": {
10278 "state": "translated",
10279 "value": "単語を補完(最後から)"
10280 }
10281 },
10282 "pt-BR": {
10283 "stringUnit": {
10284 "state": "translated",
10285 "value": "Completar Palavra, Última Primeiro"
10286 }
10287 }
10288 }
10289 },
10050 "Complete at Point": { 10290 "Complete at Point": {
10051 "comment": "Command title", 10291 "comment": "Command title",
10052 "localizations": { 10292 "localizations": {
@@ -10082,6 +10322,74 @@
10082 } 10322 }
10083 } 10323 }
10084 }, 10324 },
10325 "Completion": {
10326 "localizations": {
10327 "de": {
10328 "stringUnit": {
10329 "state": "translated",
10330 "value": "Vervollständigung"
10331 }
10332 },
10333 "es": {
10334 "stringUnit": {
10335 "state": "translated",
10336 "value": "Compleción"
10337 }
10338 },
10339 "fr": {
10340 "stringUnit": {
10341 "state": "translated",
10342 "value": "Complétion"
10343 }
10344 },
10345 "ja": {
10346 "stringUnit": {
10347 "state": "translated",
10348 "value": "補完"
10349 }
10350 },
10351 "pt-BR": {
10352 "stringUnit": {
10353 "state": "translated",
10354 "value": "Completar"
10355 }
10356 }
10357 }
10358 },
10359 "Completion list opens": {
10360 "localizations": {
10361 "de": {
10362 "stringUnit": {
10363 "state": "translated",
10364 "value": "Vervollständigungsliste öffnet sich"
10365 }
10366 },
10367 "es": {
10368 "stringUnit": {
10369 "state": "translated",
10370 "value": "La lista de compleción se abre"
10371 }
10372 },
10373 "fr": {
10374 "stringUnit": {
10375 "state": "translated",
10376 "value": "La liste de complétion s'ouvre"
10377 }
10378 },
10379 "ja": {
10380 "stringUnit": {
10381 "state": "translated",
10382 "value": "補完リストを開く"
10383 }
10384 },
10385 "pt-BR": {
10386 "stringUnit": {
10387 "state": "translated",
10388 "value": "A lista de completar abre"
10389 }
10390 }
10391 }
10392 },
10085 "Configuration": { 10393 "Configuration": {
10086 "localizations": { 10394 "localizations": {
10087 "de": { 10395 "de": {
@@ -13160,6 +13468,40 @@
13160 } 13468 }
13161 } 13469 }
13162 }, 13470 },
13471 "Doom's keys open the list by itself and match letters in order, as Doom's corfu does; the Emacs and Mac keys do neither unless set here. Expand Word completes the word before the caret from your files whatever is set.": {
13472 "localizations": {
13473 "de": {
13474 "stringUnit": {
13475 "state": "translated",
13476 "value": "Die Doom-Tasten öffnen die Liste von selbst und finden Buchstaben in Reihenfolge, wie Dooms corfu; die Emacs- und Mac-Tasten tun beides nicht, außer es ist hier eingestellt. „Wort erweitern“ vervollständigt das Wort vor der Einfügemarke aus deinen Dateien, unabhängig von diesen Einstellungen."
13477 }
13478 },
13479 "es": {
13480 "stringUnit": {
13481 "state": "translated",
13482 "value": "Las teclas de Doom abren la lista solas y buscan letras en orden, como corfu en Doom; las teclas de Emacs y Mac no hacen ninguna de las dos cosas salvo que se ajuste aquí. Expandir palabra completa la palabra antes del cursor a partir de tus archivos, con cualquier ajuste."
13483 }
13484 },
13485 "fr": {
13486 "stringUnit": {
13487 "state": "translated",
13488 "value": "Les touches Doom ouvrent la liste d'elles-mêmes et cherchent les lettres dans l'ordre, comme corfu dans Doom ; les touches Emacs et Mac ne font ni l'un ni l'autre sauf si c'est réglé ici. Développer le mot complète le mot avant le curseur à partir de vos fichiers, quels que soient ces réglages."
13489 }
13490 },
13491 "ja": {
13492 "stringUnit": {
13493 "state": "translated",
13494 "value": "Doomのキーでは、Doomのcorfuのようにリストが自動で開き、文字の順序で一致します。EmacsとMacのキーでは、ここで設定しない限りどちらも行いません。「単語を展開」は設定にかかわらず、カーソルの前の単語をファイルから補完します。"
13495 }
13496 },
13497 "pt-BR": {
13498 "stringUnit": {
13499 "state": "translated",
13500 "value": "As teclas do Doom abrem a lista sozinhas e buscam letras em ordem, como o corfu do Doom; as teclas do Emacs e do Mac não fazem nenhum dos dois, a menos que configurado aqui. Expandir Palavra completa a palavra antes do cursor a partir dos seus arquivos, qualquer que seja a configuração."
13501 }
13502 }
13503 }
13504 },
13163 "Doom's own org defaults are read from the folder Doom is installed in": { 13505 "Doom's own org defaults are read from the folder Doom is installed in": {
13164 "localizations": { 13506 "localizations": {
13165 "de": { 13507 "de": {
@@ -14844,6 +15186,41 @@
14844 } 15186 }
14845 } 15187 }
14846 }, 15188 },
15189 "Expand Word": {
15190 "comment": "Command title",
15191 "localizations": {
15192 "de": {
15193 "stringUnit": {
15194 "state": "translated",
15195 "value": "Wort erweitern"
15196 }
15197 },
15198 "es": {
15199 "stringUnit": {
15200 "state": "translated",
15201 "value": "Expandir palabra"
15202 }
15203 },
15204 "fr": {
15205 "stringUnit": {
15206 "state": "translated",
15207 "value": "Développer le mot"
15208 }
15209 },
15210 "ja": {
15211 "stringUnit": {
15212 "state": "translated",
15213 "value": "単語を展開"
15214 }
15215 },
15216 "pt-BR": {
15217 "stringUnit": {
15218 "state": "translated",
15219 "value": "Expandir Palavra"
15220 }
15221 }
15222 }
15223 },
14847 "Expanded": { 15224 "Expanded": {
14848 "localizations": { 15225 "localizations": {
14849 "de": { 15226 "de": {
@@ -18183,6 +18560,40 @@
18183 } 18560 }
18184 } 18561 }
18185 }, 18562 },
18563 "Have its letters in order, best first": {
18564 "localizations": {
18565 "de": {
18566 "stringUnit": {
18567 "state": "translated",
18568 "value": "Enthalten seine Buchstaben in Reihenfolge, beste zuerst"
18569 }
18570 },
18571 "es": {
18572 "stringUnit": {
18573 "state": "translated",
18574 "value": "Contienen sus letras en orden, las mejores primero"
18575 }
18576 },
18577 "fr": {
18578 "stringUnit": {
18579 "state": "translated",
18580 "value": "Contiennent ses lettres dans l'ordre, les meilleurs d'abord"
18581 }
18582 },
18583 "ja": {
18584 "stringUnit": {
18585 "state": "translated",
18586 "value": "文字を順に含む(一致度順)"
18587 }
18588 },
18589 "pt-BR": {
18590 "stringUnit": {
18591 "state": "translated",
18592 "value": "Têm as letras em ordem, melhores primeiro"
18593 }
18594 }
18595 }
18596 },
18186 "Headings": { 18597 "Headings": {
18187 "localizations": { 18598 "localizations": {
18188 "de": { 18599 "de": {
@@ -27447,6 +27858,40 @@
27447 } 27858 }
27448 } 27859 }
27449 }, 27860 },
27861 "Once %lld characters are typed": {
27862 "localizations": {
27863 "de": {
27864 "stringUnit": {
27865 "state": "translated",
27866 "value": "Sobald %lld Zeichen getippt sind"
27867 }
27868 },
27869 "es": {
27870 "stringUnit": {
27871 "state": "translated",
27872 "value": "Cuando se han escrito %lld caracteres"
27873 }
27874 },
27875 "fr": {
27876 "stringUnit": {
27877 "state": "translated",
27878 "value": "Dès que %lld caractères sont tapés"
27879 }
27880 },
27881 "ja": {
27882 "stringUnit": {
27883 "state": "translated",
27884 "value": "%lld 文字入力したら"
27885 }
27886 },
27887 "pt-BR": {
27888 "stringUnit": {
27889 "state": "translated",
27890 "value": "Depois de digitar %lld caracteres"
27891 }
27892 }
27893 }
27894 },
27450 "One payment, no subscription": { 27895 "One payment, no subscription": {
27451 "localizations": { 27896 "localizations": {
27452 "de": { 27897 "de": {
@@ -27617,6 +28062,40 @@
27617 } 28062 }
27618 } 28063 }
27619 }, 28064 },
28065 "Only with a key": {
28066 "localizations": {
28067 "de": {
28068 "stringUnit": {
28069 "state": "translated",
28070 "value": "Nur mit einer Taste"
28071 }
28072 },
28073 "es": {
28074 "stringUnit": {
28075 "state": "translated",
28076 "value": "Solo con una tecla"
28077 }
28078 },
28079 "fr": {
28080 "stringUnit": {
28081 "state": "translated",
28082 "value": "Seulement avec une touche"
28083 }
28084 },
28085 "ja": {
28086 "stringUnit": {
28087 "state": "translated",
28088 "value": "キーを押したときのみ"
28089 }
28090 },
28091 "pt-BR": {
28092 "stringUnit": {
28093 "state": "translated",
28094 "value": "Só com uma tecla"
28095 }
28096 }
28097 }
28098 },
27620 "Open": { 28099 "Open": {
27621 "localizations": { 28100 "localizations": {
27622 "de": { 28101 "de": {
@@ -37631,6 +38110,40 @@
37631 } 38110 }
37632 } 38111 }
37633 }, 38112 },
38113 "Start with what's typed": {
38114 "localizations": {
38115 "de": {
38116 "stringUnit": {
38117 "state": "translated",
38118 "value": "Beginnen mit dem Getippten"
38119 }
38120 },
38121 "es": {
38122 "stringUnit": {
38123 "state": "translated",
38124 "value": "Empiezan por lo escrito"
38125 }
38126 },
38127 "fr": {
38128 "stringUnit": {
38129 "state": "translated",
38130 "value": "Commencent par ce qui est tapé"
38131 }
38132 },
38133 "ja": {
38134 "stringUnit": {
38135 "state": "translated",
38136 "value": "入力した文字で始まる"
38137 }
38138 },
38139 "pt-BR": {
38140 "stringUnit": {
38141 "state": "translated",
38142 "value": "Começam com o que foi digitado"
38143 }
38144 }
38145 }
38146 },
37634 "Starting point": { 38147 "Starting point": {
37635 "localizations": { 38148 "localizations": {
37636 "de": { 38149 "de": {
@@ -40172,6 +40685,40 @@
40172 } 40685 }
40173 } 40686 }
40174 }, 40687 },
40688 "The list offers words from open files and folders": {
40689 "localizations": {
40690 "de": {
40691 "stringUnit": {
40692 "state": "translated",
40693 "value": "Die Liste bietet Wörter aus offenen Dateien und Ordnern an"
40694 }
40695 },
40696 "es": {
40697 "stringUnit": {
40698 "state": "translated",
40699 "value": "La lista ofrece palabras de archivos abiertos y carpetas"
40700 }
40701 },
40702 "fr": {
40703 "stringUnit": {
40704 "state": "translated",
40705 "value": "La liste propose des mots des fichiers ouverts et des dossiers"
40706 }
40707 },
40708 "ja": {
40709 "stringUnit": {
40710 "state": "translated",
40711 "value": "開いているファイルとフォルダの単語をリストに表示"
40712 }
40713 },
40714 "pt-BR": {
40715 "stringUnit": {
40716 "state": "translated",
40717 "value": "A lista oferece palavras de arquivos abertos e pastas"
40718 }
40719 }
40720 }
40721 },
40175 "The next agenda entry, or how many are open today.": { 40722 "The next agenda entry, or how many are open today.": {
40176 "localizations": { 40723 "localizations": {
40177 "de": { 40724 "de": {
@@ -43411,6 +43958,40 @@
43411 } 43958 }
43412 } 43959 }
43413 }, 43960 },
43961 "With a hardware keyboard. Doom's keys open the list by itself and match letters in order, as Doom's corfu does; the Emacs and Mac keys do neither unless set here.": {
43962 "localizations": {
43963 "de": {
43964 "stringUnit": {
43965 "state": "translated",
43966 "value": "Mit einer Hardwaretastatur. Die Doom-Tasten öffnen die Liste von selbst und finden Buchstaben in Reihenfolge, wie Dooms corfu; die Emacs- und Mac-Tasten tun beides nicht, außer es ist hier eingestellt."
43967 }
43968 },
43969 "es": {
43970 "stringUnit": {
43971 "state": "translated",
43972 "value": "Con un teclado físico. Las teclas de Doom abren la lista solas y buscan letras en orden, como corfu en Doom; las teclas de Emacs y Mac no hacen ninguna de las dos cosas salvo que se ajuste aquí."
43973 }
43974 },
43975 "fr": {
43976 "stringUnit": {
43977 "state": "translated",
43978 "value": "Avec un clavier physique. Les touches Doom ouvrent la liste d'elles-mêmes et cherchent les lettres dans l'ordre, comme corfu dans Doom ; les touches Emacs et Mac ne font ni l'un ni l'autre sauf si c'est réglé ici."
43979 }
43980 },
43981 "ja": {
43982 "stringUnit": {
43983 "state": "translated",
43984 "value": "ハードウェアキーボード使用時。Doomのキーでは、Doomのcorfuのようにリストが自動で開き、文字の順序で一致します。EmacsとMacのキーでは、ここで設定しない限りどちらも行いません。"
43985 }
43986 },
43987 "pt-BR": {
43988 "stringUnit": {
43989 "state": "translated",
43990 "value": "Com um teclado físico. As teclas do Doom abrem a lista sozinhas e buscam letras em ordem, como o corfu do Doom; as teclas do Emacs e do Mac não fazem nenhum dos dois, a menos que configurado aqui."
43991 }
43992 }
43993 }
43994 },
43414 "Word Count": { 43995 "Word Count": {
43415 "localizations": { 43996 "localizations": {
43416 "de": { 43997 "de": {
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form