Skip to content

Autocomplete Implementation #1949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions CodeEdit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
6C6BD6F829CD14D100235D17 /* CodeEditKit in Frameworks */ = {isa = PBXBuildFile; productRef = 6C6BD6F729CD14D100235D17 /* CodeEditKit */; };
6C6BD6F929CD14D100235D17 /* CodeEditKit in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 6C6BD6F729CD14D100235D17 /* CodeEditKit */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
6C73A6D32D4F1E550012D95C /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6C73A6D22D4F1E550012D95C /* CodeEditSourceEditor */; };
6C76D6D42E15B91E00EF52C3 /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6C76D6D32E15B91E00EF52C3 /* CodeEditSourceEditor */; };
6C81916B29B41DD300B75C92 /* DequeModule in Frameworks */ = {isa = PBXBuildFile; productRef = 6C81916A29B41DD300B75C92 /* DequeModule */; };
6C85BB402C2105ED00EB5DEF /* CodeEditKit in Frameworks */ = {isa = PBXBuildFile; productRef = 6C85BB3F2C2105ED00EB5DEF /* CodeEditKit */; };
6C85BB442C210EFD00EB5DEF /* SwiftUIIntrospect in Frameworks */ = {isa = PBXBuildFile; productRef = 6C85BB432C210EFD00EB5DEF /* SwiftUIIntrospect */; };
6C8B56492E2FE62E00DC3F29 /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6C8B56482E2FE62E00DC3F29 /* CodeEditSourceEditor */; };
6C9DB9E42D55656300ACD86E /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6C9DB9E32D55656300ACD86E /* CodeEditSourceEditor */; };
6CAAF68A29BC9C2300A1F48A /* (null) in Sources */ = {isa = PBXBuildFile; };
6CAAF69229BCC71C00A1F48A /* (null) in Sources */ = {isa = PBXBuildFile; };
Expand Down Expand Up @@ -176,7 +176,6 @@
58F2EB1E292FB954004A9BDE /* Sparkle in Frameworks */,
6C147C4529A329350089B630 /* OrderedCollections in Frameworks */,
6CE21E872C650D2C0031B056 /* SwiftTerm in Frameworks */,
6C76D6D42E15B91E00EF52C3 /* CodeEditSourceEditor in Frameworks */,
6CCF73D02E26DE3200B94F75 /* SwiftTerm in Frameworks */,
6C315FC82E05E33D0011BFC5 /* CodeEditSourceEditor in Frameworks */,
6CC00A8B2CBEF150004E8134 /* CodeEditSourceEditor in Frameworks */,
Expand All @@ -192,6 +191,7 @@
6C73A6D32D4F1E550012D95C /* CodeEditSourceEditor in Frameworks */,
2816F594280CF50500DD548B /* CodeEditSymbols in Frameworks */,
30CB64942C16CA9100CC8A9E /* LanguageClient in Frameworks */,
6C8B56492E2FE62E00DC3F29 /* CodeEditSourceEditor in Frameworks */,
5EACE6222DF4BF08005E08B8 /* WelcomeWindow in Frameworks */,
6C6BD6F829CD14D100235D17 /* CodeEditKit in Frameworks */,
6C0824A12C5C0C9700A0751E /* SwiftTerm in Frameworks */,
Expand Down Expand Up @@ -323,7 +323,6 @@
6C0617D52BDB4432008C9C42 /* LogStream */,
6C85BB3F2C2105ED00EB5DEF /* CodeEditKit */,
6C85BB432C210EFD00EB5DEF /* SwiftUIIntrospect */,
6CC17B4E2C432AE000834E2C /* CodeEditSourceEditor */,
6C0824A02C5C0C9700A0751E /* SwiftTerm */,
6CE21E862C650D2C0031B056 /* SwiftTerm */,
6CD3CA542C8B508200D83DCD /* CodeEditSourceEditor */,
Expand All @@ -334,9 +333,9 @@
5EACE6212DF4BF08005E08B8 /* WelcomeWindow */,
5E4485602DF600D9008BBE69 /* AboutWindow */,
6C315FC72E05E33D0011BFC5 /* CodeEditSourceEditor */,
6C76D6D32E15B91E00EF52C3 /* CodeEditSourceEditor */,
6CCF6DD22E26D48F00B94F75 /* SwiftTerm */,
6CCF73CF2E26DE3200B94F75 /* SwiftTerm */,
6C8B56482E2FE62E00DC3F29 /* CodeEditSourceEditor */,
);
productName = CodeEdit;
productReference = B658FB2C27DA9E0F00EA4DBD /* CodeEdit.app */;
Expand Down Expand Up @@ -441,8 +440,8 @@
30ED7B722DD299E600ACC922 /* XCRemoteSwiftPackageReference "ZIPFoundation" */,
5EACE6202DF4BF08005E08B8 /* XCRemoteSwiftPackageReference "WelcomeWindow" */,
5E44855F2DF600D9008BBE69 /* XCRemoteSwiftPackageReference "AboutWindow" */,
6C76D6D22E15B91E00EF52C3 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */,
6CCF73CE2E26DE3200B94F75 /* XCRemoteSwiftPackageReference "SwiftTerm" */,
6C8B56472E2FE62E00DC3F29 /* XCLocalSwiftPackageReference "../CodeEditSourceEditor" */,
);
preferredProjectObjectVersion = 55;
productRefGroup = B658FB2D27DA9E0F00EA4DBD /* Products */;
Expand Down Expand Up @@ -1649,6 +1648,13 @@
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
6C8B56472E2FE62E00DC3F29 /* XCLocalSwiftPackageReference "../CodeEditSourceEditor" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../CodeEditSourceEditor;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCRemoteSwiftPackageReference section */
2816F592280CF50500DD548B /* XCRemoteSwiftPackageReference "CodeEditSymbols" */ = {
isa = XCRemoteSwiftPackageReference;
Expand Down Expand Up @@ -1778,14 +1784,6 @@
minimumVersion = 0.2.0;
};
};
6C76D6D22E15B91E00EF52C3 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor";
requirement = {
kind = exactVersion;
version = 0.14.1;
};
};
6C85BB3E2C2105ED00EB5DEF /* XCRemoteSwiftPackageReference "CodeEditKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/CodeEditApp/CodeEditKit";
Expand Down Expand Up @@ -1905,11 +1903,6 @@
isa = XCSwiftPackageProductDependency;
productName = CodeEditSourceEditor;
};
6C76D6D32E15B91E00EF52C3 /* CodeEditSourceEditor */ = {
isa = XCSwiftPackageProductDependency;
package = 6C76D6D22E15B91E00EF52C3 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */;
productName = CodeEditSourceEditor;
};
6C7B1C752A1D57CE005CBBFC /* SwiftLint */ = {
isa = XCSwiftPackageProductDependency;
package = 287136B1292A407E00E9F5F4 /* XCRemoteSwiftPackageReference "SwiftLintPlugin" */;
Expand All @@ -1930,6 +1923,10 @@
package = 6C85BB422C210EFD00EB5DEF /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */;
productName = SwiftUIIntrospect;
};
6C8B56482E2FE62E00DC3F29 /* CodeEditSourceEditor */ = {
isa = XCSwiftPackageProductDependency;
productName = CodeEditSourceEditor;
};
6C9DB9E32D55656300ACD86E /* CodeEditSourceEditor */ = {
isa = XCSwiftPackageProductDependency;
package = 6C9DB9E22D55656300ACD86E /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Foundation
import SwiftUI
import UniformTypeIdentifiers
import CodeEditSourceEditor
import CodeEditTextView
import CodeEditLanguages
import Combine
import OSLog
Expand Down
3 changes: 3 additions & 0 deletions CodeEdit/Features/Editor/Models/EditorInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class EditorInstance: ObservableObject, Hashable {
@Published var replaceText: String?
var replaceTextSubject: PassthroughSubject<String?, Never>

var autoCompleteCoordinator: AutoCompleteCoordinator?

var rangeTranslator: RangeTranslator = RangeTranslator()

private var cancellables: Set<AnyCancellable> = []
Expand All @@ -37,6 +39,7 @@ class EditorInstance: ObservableObject, Hashable {
self.file = file
let url = file.url
let editorState = EditorStateRestoration.shared?.restorationState(for: url)
self.autoCompleteCoordinator = AutoCompleteCoordinator(file)

findText = workspace?.searchState?.searchQuery
findTextSubject = PassthroughSubject()
Expand Down
3 changes: 2 additions & 1 deletion CodeEdit/Features/Editor/Views/CodeFileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ struct CodeFileView: View {
),
highlightProviders: highlightProviders,
undoManager: undoRegistration.manager(forFile: editorInstance.file),
coordinators: textViewCoordinators
coordinators: textViewCoordinators,
completionDelegate: editorInstance.autoCompleteCoordinator
)
// This view needs to refresh when the codefile changes. The file URL is too stable.
.id(ObjectIdentifier(codeFile))
Expand Down
Loading
Loading