Skip to content

Commit b75eedf

Browse files
committed
Improve completionDelegate Documentation
1 parent 4f45ada commit b75eedf

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Sources/CodeEditSourceEditor/Controller/TextViewController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public class TextViewController: NSViewController {
8585
/// The provided highlight provider.
8686
public var highlightProviders: [HighlightProviding]
8787

88+
/// A delegate object that can respond to requests for completion items, filtering completion items, and triggering
89+
/// the suggestion window. See ``CodeSuggestionDelegate``.
90+
/// - Note: The ``TextViewController`` keeps only a `weak` reference to this object. To function properly, ensure a
91+
/// strong reference to the delegate is kept *outside* of this variable.
8892
public weak var completionDelegate: CodeSuggestionDelegate?
8993

9094
/// A delegate object that responds to requests for jump to definition actions. see ``JumpToDefinitionDelegate``.
@@ -225,6 +229,7 @@ public class TextViewController: NSViewController {
225229
foldProvider: LineFoldProvider? = nil,
226230
undoManager: CEUndoManager? = nil,
227231
coordinators: [TextViewCoordinator] = [],
232+
completionDelegate: CodeSuggestionDelegate? = nil,
228233
jumpToDefinitionDelegate: JumpToDefinitionDelegate? = nil
229234
) {
230235
self.language = language
@@ -234,6 +239,7 @@ public class TextViewController: NSViewController {
234239
self.foldProvider = foldProvider ?? LineIndentationFoldProvider()
235240
self._undoManager = undoManager
236241
self.invisibleCharactersCoordinator = InvisibleCharactersCoordinator(configuration: configuration)
242+
self.completionDelegate = completionDelegate
237243
self.jumpToDefinitionModel = JumpToDefinitionModel(
238244
controller: nil,
239245
treeSitterClient: treeSitterClient,

Sources/CodeEditSourceEditor/Documentation.docc/SourceEditorView.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ let editorController = TextViewController(
8787
highlightProviders: [], // Use the tree-sitter syntax highlighting provider by default
8888
undoManager: nil,
8989
coordinators: [], // Optionally inject editing behavior or other plugins.
90+
completionDelegate: nil, // Provide code suggestions while typing via a delegate object.
9091
jumpToDefinitionDelegate // Allow users to perform the 'jump to definition' using a delegate object.
9192
)
9293
```

0 commit comments

Comments
 (0)