Skip to content

Commit f705595

Browse files
LSP Document Content Sync (#1887)
* Rework LSP To Use Workspace Files, Standardize Errors * Shutdown Servers When Workspace Closes * Add Document Sync Tests * Begin Sync Work, Need To Fix Status Bar Label * Clean Up Documentation * Fixed Cursor Position Label * Fix Subtle FileManager Bug, Fix Duplicate File Reads * Remove code causing a malloc exception, See #1886 * Fix File Opening Bug, Finish Cursor Fix * Remove Extra Service * Remove Extra `internal` * Throttle Content Updates * Throttle Edit Notifications, Tests * Revert Editor Model Changes
1 parent 5967466 commit f705595

File tree

14 files changed

+523
-177
lines changed

14 files changed

+523
-177
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@
377377
6C1CC99B2B1E7CBC0002349B /* FindNavigatorIndexBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C1CC99A2B1E7CBC0002349B /* FindNavigatorIndexBar.swift */; };
378378
6C1F3DA22C18C55800F6DEF6 /* ShellIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C1F3DA12C18C55800F6DEF6 /* ShellIntegrationTests.swift */; };
379379
6C23842F2C796B4C003FBDD4 /* GitChangedFileLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C23842E2C796B4C003FBDD4 /* GitChangedFileLabel.swift */; };
380+
6C278CC72C93971F0066F6D9 /* LSPContentCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C278CC62C93971F0066F6D9 /* LSPContentCoordinator.swift */; };
380381
6C2C155829B4F49100EA60A5 /* SplitViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C2C155729B4F49100EA60A5 /* SplitViewItem.swift */; };
381382
6C2C155A29B4F4CC00EA60A5 /* Variadic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C2C155929B4F4CC00EA60A5 /* Variadic.swift */; };
382383
6C2C155D29B4F4E500EA60A5 /* SplitViewReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C2C155C29B4F4E500EA60A5 /* SplitViewReader.swift */; };
@@ -444,6 +445,8 @@
444445
6CB446402B6DFF3A00539ED0 /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6CB4463F2B6DFF3A00539ED0 /* CodeEditSourceEditor */; };
445446
6CB52DC92AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB52DC82AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift */; };
446447
6CB9144B29BEC7F100BC47F2 /* (null) in Sources */ = {isa = PBXBuildFile; };
448+
6CB94CFE2C9F1C9A00E8651C /* TextView+LSPRange.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB94CFD2C9F1C9A00E8651C /* TextView+LSPRange.swift */; };
449+
6CB94D032CA1205100E8651C /* AsyncAlgorithms in Frameworks */ = {isa = PBXBuildFile; productRef = 6CB94D022CA1205100E8651C /* AsyncAlgorithms */; };
447450
6CBA0D512A1BF524002C6FAA /* SegmentedControlImproved.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBA0D502A1BF524002C6FAA /* SegmentedControlImproved.swift */; };
448451
6CBD1BC62978DE53006639D5 /* Font+Caption3.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBD1BC52978DE53006639D5 /* Font+Caption3.swift */; };
449452
6CBE1CFB2B71DAA6003AC32E /* Loopable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBE1CFA2B71DAA6003AC32E /* Loopable.swift */; };
@@ -1048,6 +1051,7 @@
10481051
6C1CC99A2B1E7CBC0002349B /* FindNavigatorIndexBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindNavigatorIndexBar.swift; sourceTree = "<group>"; };
10491052
6C1F3DA12C18C55800F6DEF6 /* ShellIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellIntegrationTests.swift; sourceTree = "<group>"; };
10501053
6C23842E2C796B4C003FBDD4 /* GitChangedFileLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GitChangedFileLabel.swift; sourceTree = "<group>"; };
1054+
6C278CC62C93971F0066F6D9 /* LSPContentCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LSPContentCoordinator.swift; sourceTree = "<group>"; };
10511055
6C2C155729B4F49100EA60A5 /* SplitViewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitViewItem.swift; sourceTree = "<group>"; };
10521056
6C2C155929B4F4CC00EA60A5 /* Variadic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Variadic.swift; sourceTree = "<group>"; };
10531057
6C2C155C29B4F4E500EA60A5 /* SplitViewReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitViewReader.swift; sourceTree = "<group>"; };
@@ -1103,6 +1107,7 @@
11031107
6CA1AE942B46950000378EAB /* EditorInstance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorInstance.swift; sourceTree = "<group>"; };
11041108
6CABB1A029C5593800340467 /* SearchPanelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchPanelView.swift; sourceTree = "<group>"; };
11051109
6CB52DC82AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CEWorkspaceFileManager+FileManagement.swift"; sourceTree = "<group>"; };
1110+
6CB94CFD2C9F1C9A00E8651C /* TextView+LSPRange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TextView+LSPRange.swift"; sourceTree = "<group>"; };
11061111
6CBA0D502A1BF524002C6FAA /* SegmentedControlImproved.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentedControlImproved.swift; sourceTree = "<group>"; };
11071112
6CBD1BC52978DE53006639D5 /* Font+Caption3.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Font+Caption3.swift"; sourceTree = "<group>"; };
11081113
6CBE1CFA2B71DAA6003AC32E /* Loopable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Loopable.swift; sourceTree = "<group>"; };
@@ -1310,6 +1315,7 @@
13101315
6C6BD6F829CD14D100235D17 /* CodeEditKit in Frameworks */,
13111316
6C0824A12C5C0C9700A0751E /* SwiftTerm in Frameworks */,
13121317
6C81916B29B41DD300B75C92 /* DequeModule in Frameworks */,
1318+
6CB94D032CA1205100E8651C /* AsyncAlgorithms in Frameworks */,
13131319
);
13141320
runOnlyForDeploymentPostprocessing = 0;
13151321
};
@@ -1552,7 +1558,6 @@
15521558
30B087FB2C0D53080063A882 /* LSP */ = {
15531559
isa = PBXGroup;
15541560
children = (
1555-
6CD26C822C8F8A5F00ADBA38 /* Extensions */,
15561561
6CD26C732C8EA71F00ADBA38 /* LanguageServer */,
15571562
6CD26C742C8EA79100ADBA38 /* Service */,
15581563
30B087FA2C0D53080063A882 /* LSPUtil.swift */,
@@ -2442,9 +2447,11 @@
24422447
5831E3C62933E7E600D5A6D2 /* Color */,
24432448
669A504F2C380BFD00304CD8 /* Collection */,
24442449
5831E3C82933E80500D5A6D2 /* Date */,
2450+
6CB94D002C9F1CF900E8651C /* LanguageIdentifier */,
24452451
6C82D6C429C0129E00495C54 /* NSApplication */,
24462452
5831E3D02934036D00D5A6D2 /* NSTableView */,
24472453
77A01E922BCA9C0400F0EA38 /* NSWindow */,
2454+
6CB94CFF2C9F1CB600E8651C /* TextView */,
24482455
77EF6C042C57DE4B00984B69 /* URL */,
24492456
58D01C8B293167DC00C5B6B4 /* String */,
24502457
5831E3CB2933E89A00D5A6D2 /* SwiftTerm */,
@@ -2968,6 +2975,22 @@
29682975
path = WindowCommands;
29692976
sourceTree = "<group>";
29702977
};
2978+
6CB94CFF2C9F1CB600E8651C /* TextView */ = {
2979+
isa = PBXGroup;
2980+
children = (
2981+
6CB94CFD2C9F1C9A00E8651C /* TextView+LSPRange.swift */,
2982+
);
2983+
path = TextView;
2984+
sourceTree = "<group>";
2985+
};
2986+
6CB94D002C9F1CF900E8651C /* LanguageIdentifier */ = {
2987+
isa = PBXGroup;
2988+
children = (
2989+
6CD26C802C8F8A4400ADBA38 /* LanguageIdentifier+CodeLanguage.swift */,
2990+
);
2991+
path = LanguageIdentifier;
2992+
sourceTree = "<group>";
2993+
};
29712994
6CBD1BC42978DE3E006639D5 /* Text */ = {
29722995
isa = PBXGroup;
29732996
children = (
@@ -3006,6 +3029,7 @@
30063029
6CD26C6D2C8EA1E600ADBA38 /* LanguageServerFileMap.swift */,
30073030
6CD26C782C8EA8A500ADBA38 /* LSPCache.swift */,
30083031
6CD26C792C8EA8A500ADBA38 /* LSPCache+Data.swift */,
3032+
6C278CC62C93971F0066F6D9 /* LSPContentCoordinator.swift */,
30093033
30B0881E2C12626B0063A882 /* Capabilities */,
30103034
);
30113035
path = LanguageServer;
@@ -3030,14 +3054,6 @@
30303054
path = URL;
30313055
sourceTree = "<group>";
30323056
};
3033-
6CD26C822C8F8A5F00ADBA38 /* Extensions */ = {
3034-
isa = PBXGroup;
3035-
children = (
3036-
6CD26C802C8F8A4400ADBA38 /* LanguageIdentifier+CodeLanguage.swift */,
3037-
);
3038-
path = Extensions;
3039-
sourceTree = "<group>";
3040-
};
30413057
6CD26C882C8F91B600ADBA38 /* LSP */ = {
30423058
isa = PBXGroup;
30433059
children = (
@@ -3678,6 +3694,7 @@
36783694
6C4E37FB2C73E00700AEE7B5 /* SwiftTerm */,
36793695
6CD3CA542C8B508200D83DCD /* CodeEditSourceEditor */,
36803696
6CD26C842C8F907800ADBA38 /* CodeEditSourceEditor */,
3697+
6CB94D022CA1205100E8651C /* AsyncAlgorithms */,
36813698
);
36823699
productName = CodeEdit;
36833700
productReference = B658FB2C27DA9E0F00EA4DBD /* CodeEdit.app */;
@@ -3775,6 +3792,7 @@
37753792
303E88462C276FD600EEA8D9 /* XCRemoteSwiftPackageReference "LanguageServerProtocol" */,
37763793
6C4E37FA2C73E00700AEE7B5 /* XCRemoteSwiftPackageReference "SwiftTerm" */,
37773794
6CD26C832C8F907800ADBA38 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */,
3795+
6CB94D012CA1205100E8651C /* XCRemoteSwiftPackageReference "swift-async-algorithms" */,
37783796
);
37793797
productRefGroup = B658FB2D27DA9E0F00EA4DBD /* Products */;
37803798
projectDirPath = "";
@@ -4357,6 +4375,7 @@
43574375
5878DA82291863F900DD95A3 /* AcknowledgementsView.swift in Sources */,
43584376
587B9E8529301D8F00AC7927 /* GitHubReview.swift in Sources */,
43594377
58D01C9A293167DC00C5B6B4 /* CodeEditKeychain.swift in Sources */,
4378+
6CB94CFE2C9F1C9A00E8651C /* TextView+LSPRange.swift in Sources */,
43604379
B6966A2E2C3056AD00259C2D /* SourceControlCommands.swift in Sources */,
43614380
B62AEDAA2A1FCBE5009A9F52 /* AreaTabBar.swift in Sources */,
43624381
20D839AB280DEB2900B27357 /* NoSelectionInspectorView.swift in Sources */,
@@ -4399,6 +4418,7 @@
43994418
6C1CC9982B1E770B0002349B /* AsyncFileIterator.swift in Sources */,
44004419
587B9E9029301D8F00AC7927 /* BitBucketTokenRouter.swift in Sources */,
44014420
B6C6A42E29771A8D00A3D28F /* EditorTabButtonStyle.swift in Sources */,
4421+
6C278CC72C93971F0066F6D9 /* LSPContentCoordinator.swift in Sources */,
44024422
58822525292C280D00E83CDE /* StatusBarMenuStyle.swift in Sources */,
44034423
6C147C4229A328C10089B630 /* Editor.swift in Sources */,
44044424
B6C4F2A32B3CA74800B2B140 /* CommitDetailsView.swift in Sources */,
@@ -5659,12 +5679,20 @@
56595679
minimumVersion = 1.2.0;
56605680
};
56615681
};
5682+
6CB94D012CA1205100E8651C /* XCRemoteSwiftPackageReference "swift-async-algorithms" */ = {
5683+
isa = XCRemoteSwiftPackageReference;
5684+
repositoryURL = "https://github.com/apple/swift-async-algorithms.git";
5685+
requirement = {
5686+
kind = exactVersion;
5687+
version = 1.0.1;
5688+
};
5689+
};
56625690
6CD26C832C8F907800ADBA38 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */ = {
56635691
isa = XCRemoteSwiftPackageReference;
56645692
repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor";
56655693
requirement = {
56665694
kind = upToNextMajorVersion;
5667-
minimumVersion = 0.8.0;
5695+
minimumVersion = 0.8.1;
56685696
};
56695697
};
56705698
/* End XCRemoteSwiftPackageReference section */
@@ -5752,6 +5780,11 @@
57525780
isa = XCSwiftPackageProductDependency;
57535781
productName = CodeEditSourceEditor;
57545782
};
5783+
6CB94D022CA1205100E8651C /* AsyncAlgorithms */ = {
5784+
isa = XCSwiftPackageProductDependency;
5785+
package = 6CB94D012CA1205100E8651C /* XCRemoteSwiftPackageReference "swift-async-algorithms" */;
5786+
productName = AsyncAlgorithms;
5787+
};
57555788
6CC17B4E2C432AE000834E2C /* CodeEditSourceEditor */ = {
57565789
isa = XCSwiftPackageProductDependency;
57575790
productName = CodeEditSourceEditor;

CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"originHash" : "b6e0c892d567c4fb43e4135487752085a69cf403b95ee27c28e9d213dd3bbf5c",
2+
"originHash" : "5c4a5d433333474763817b9804d7f1856ab3b416ed87b190a2bd6e86c0c9834c",
33
"pins" : [
44
{
55
"identity" : "anycodable",
@@ -13,7 +13,7 @@
1313
{
1414
"identity" : "codeeditkit",
1515
"kind" : "remoteSourceControl",
16-
"location" : "https://github.com/CodeEditApp/CodeEditKit",
16+
"location" : "https://github.com/CodeEditApp/CodeEditKit.git",
1717
"state" : {
1818
"revision" : "ad28213a968586abb0cb21a8a56a3587227895f1",
1919
"version" : "0.1.2"
@@ -33,8 +33,8 @@
3333
"kind" : "remoteSourceControl",
3434
"location" : "https://github.com/CodeEditApp/CodeEditSourceEditor",
3535
"state" : {
36-
"revision" : "7d08e741c412b6fd30d5eea8bb6c0580e89553cf",
37-
"version" : "0.8.0"
36+
"revision" : "033b68d3e3e845984fbc3d405720d5cc6ce61f71",
37+
"version" : "0.8.1"
3838
}
3939
},
4040
{
@@ -181,6 +181,15 @@
181181
"version" : "2.3.0"
182182
}
183183
},
184+
{
185+
"identity" : "swift-async-algorithms",
186+
"kind" : "remoteSourceControl",
187+
"location" : "https://github.com/apple/swift-async-algorithms.git",
188+
"state" : {
189+
"revision" : "6ae9a051f76b81cc668305ceed5b0e0a7fd93d20",
190+
"version" : "1.0.1"
191+
}
192+
},
184193
{
185194
"identity" : "swift-collections",
186195
"kind" : "remoteSourceControl",

CodeEdit/Features/Documents/CodeFileDocument/CodeFileDocument.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ final class CodeFileDocument: NSDocument, ObservableObject {
4747
/// See ``CodeEditSourceEditor/CombineCoordinator``.
4848
@Published var contentCoordinator: CombineCoordinator = CombineCoordinator()
4949

50+
lazy var languageServerCoordinator: LSPContentCoordinator = {
51+
let coordinator = LSPContentCoordinator()
52+
coordinator.uri = self.languageServerURI
53+
return coordinator
54+
}()
55+
5056
/// Used to override detected languages.
5157
@Published var language: CodeLanguage?
5258

CodeEdit/Features/Editor/Views/CodeFileView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ struct CodeFileView: View {
5656

5757
init(codeFile: CodeFileDocument, textViewCoordinators: [TextViewCoordinator] = [], isEditable: Bool = true) {
5858
self._codeFile = .init(wrappedValue: codeFile)
59-
self.textViewCoordinators = textViewCoordinators + [codeFile.contentCoordinator]
59+
self.textViewCoordinators = textViewCoordinators + [
60+
codeFile.contentCoordinator,
61+
codeFile.languageServerCoordinator
62+
]
6063
self.isEditable = isEditable
6164

6265
if let openOptions = codeFile.openOptions {

CodeEdit/Features/Extensions/ExtensionDiscovery.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ final class ExtensionDiscovery: ObservableObject {
7777
Task { [weak self] in
7878
for await availability in AppExtensionIdentity.availabilityUpdates {
7979
guard !Task.isCancelled && self != nil else { return }
80-
print(availability)
8180
do {
8281
if availability.disabledCount > 0 {
8382
print("Found \(availability.disabledCount) disabled extensions, trying to activate...")

0 commit comments

Comments
 (0)