Skip to content

Commit bbcc8c0

Browse files
Implementing Fundamental Indexing (#1483)
* Basic indexing * Implemented indexing * Added async searching * Added LayzFilePathEnumerator * Improved search func * Removed whitespace * Improved async searching * Slight improvements and more documentation * Removed unnecessary code * Fine tuning * Apply suggestions from code review Co-authored-by: Khan Winter <35942988+thecoolwinter@users.noreply.github.com> * CanReplace defaults to true * clear button resets search results * Only add results if the results has line matches * Replaced .split with .components * Out-of-Bounds Safety --------- Co-authored-by: Khan Winter <35942988+thecoolwinter@users.noreply.github.com>
1 parent 7247ad4 commit bbcc8c0

18 files changed

Lines changed: 1363 additions & 110 deletions

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,19 @@
259259
58FD7608291EA1CB0051D6E4 /* CommandPaletteViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FD7605291EA1CB0051D6E4 /* CommandPaletteViewModel.swift */; };
260260
58FD7609291EA1CB0051D6E4 /* CommandPaletteView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FD7607291EA1CB0051D6E4 /* CommandPaletteView.swift */; };
261261
5C4BB1E128212B1E00A92FB2 /* World.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C4BB1E028212B1E00A92FB2 /* World.swift */; };
262+
611191FA2B08CC9000D4459B /* SearchIndexer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 611191F92B08CC9000D4459B /* SearchIndexer.swift */; };
263+
611191FC2B08CCB800D4459B /* SearchIndexer+AsyncController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 611191FB2B08CCB800D4459B /* SearchIndexer+AsyncController.swift */; };
264+
611191FE2B08CCD200D4459B /* SearchIndexer+File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 611191FD2B08CCD200D4459B /* SearchIndexer+File.swift */; };
265+
611192002B08CCD700D4459B /* SearchIndexer+Memory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 611191FF2B08CCD700D4459B /* SearchIndexer+Memory.swift */; };
266+
611192022B08CCDC00D4459B /* SearchIndexer+Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 611192012B08CCDC00D4459B /* SearchIndexer+Search.swift */; };
267+
611192042B08CCED00D4459B /* SearchIndexer+ProgressivSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 611192032B08CCED00D4459B /* SearchIndexer+ProgressivSearch.swift */; };
268+
611192062B08CCF600D4459B /* SearchIndexer+Add.swift in Sources */ = {isa = PBXBuildFile; fileRef = 611192052B08CCF600D4459B /* SearchIndexer+Add.swift */; };
269+
611192082B08CCFD00D4459B /* SearchIndexer+Terms.swift in Sources */ = {isa = PBXBuildFile; fileRef = 611192072B08CCFD00D4459B /* SearchIndexer+Terms.swift */; };
270+
6111920C2B08CD0B00D4459B /* SearchIndexer+InternalMethods.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6111920B2B08CD0B00D4459B /* SearchIndexer+InternalMethods.swift */; };
271+
613DF55E2B08DD5D00E9D902 /* FileHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 613DF55D2B08DD5D00E9D902 /* FileHelper.swift */; };
272+
61538B902B111FE800A88846 /* String+AppearancesOfSubstring.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61538B8F2B111FE800A88846 /* String+AppearancesOfSubstring.swift */; };
273+
61538B932B11201900A88846 /* String+Character.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61538B922B11201900A88846 /* String+Character.swift */; };
274+
615AA21A2B0CFD480013FCCC /* LazyStringLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 615AA2192B0CFD480013FCCC /* LazyStringLoader.swift */; };
262275
6C049A372A49E2DB00D42923 /* DirectoryEventStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C049A362A49E2DB00D42923 /* DirectoryEventStream.swift */; };
263276
6C05A8AF284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C05A8AE284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift */; };
264277
6C092EC62A4E803300489202 /* CodeEditTextView in Frameworks */ = {isa = PBXBuildFile; productRef = 6C092EC52A4E803300489202 /* CodeEditTextView */; };
@@ -746,6 +759,19 @@
746759
58FD7605291EA1CB0051D6E4 /* CommandPaletteViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommandPaletteViewModel.swift; sourceTree = "<group>"; };
747760
58FD7607291EA1CB0051D6E4 /* CommandPaletteView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommandPaletteView.swift; sourceTree = "<group>"; };
748761
5C4BB1E028212B1E00A92FB2 /* World.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = World.swift; sourceTree = "<group>"; };
762+
611191F92B08CC9000D4459B /* SearchIndexer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchIndexer.swift; sourceTree = "<group>"; };
763+
611191FB2B08CCB800D4459B /* SearchIndexer+AsyncController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchIndexer+AsyncController.swift"; sourceTree = "<group>"; };
764+
611191FD2B08CCD200D4459B /* SearchIndexer+File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchIndexer+File.swift"; sourceTree = "<group>"; };
765+
611191FF2B08CCD700D4459B /* SearchIndexer+Memory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchIndexer+Memory.swift"; sourceTree = "<group>"; };
766+
611192012B08CCDC00D4459B /* SearchIndexer+Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchIndexer+Search.swift"; sourceTree = "<group>"; };
767+
611192032B08CCED00D4459B /* SearchIndexer+ProgressivSearch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchIndexer+ProgressivSearch.swift"; sourceTree = "<group>"; };
768+
611192052B08CCF600D4459B /* SearchIndexer+Add.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchIndexer+Add.swift"; sourceTree = "<group>"; };
769+
611192072B08CCFD00D4459B /* SearchIndexer+Terms.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchIndexer+Terms.swift"; sourceTree = "<group>"; };
770+
6111920B2B08CD0B00D4459B /* SearchIndexer+InternalMethods.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchIndexer+InternalMethods.swift"; sourceTree = "<group>"; };
771+
613DF55D2B08DD5D00E9D902 /* FileHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileHelper.swift; sourceTree = "<group>"; };
772+
61538B8F2B111FE800A88846 /* String+AppearancesOfSubstring.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+AppearancesOfSubstring.swift"; sourceTree = "<group>"; };
773+
61538B922B11201900A88846 /* String+Character.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Character.swift"; sourceTree = "<group>"; };
774+
615AA2192B0CFD480013FCCC /* LazyStringLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyStringLoader.swift; sourceTree = "<group>"; };
749775
6C049A362A49E2DB00D42923 /* DirectoryEventStream.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectoryEventStream.swift; sourceTree = "<group>"; };
750776
6C05A8AE284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WorkspaceDocument+Listeners.swift"; sourceTree = "<group>"; };
751777
6C092ED92A53A58600489202 /* EditorLayout+StateRestoration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EditorLayout+StateRestoration.swift"; sourceTree = "<group>"; };
@@ -959,8 +985,12 @@
959985
5831E3CF2933F4E000D5A6D2 /* Views */,
960986
043C321527E3201F006AE443 /* WorkspaceDocument.swift */,
961987
043BCF02281DA18A000AC47C /* WorkspaceDocument+Search.swift */,
988+
615AA2192B0CFD480013FCCC /* LazyStringLoader.swift */,
962989
6C05A8AE284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift */,
963990
6C092EDF2A53BFCF00489202 /* WorkspaceStateKey.swift */,
991+
61538B8F2B111FE800A88846 /* String+AppearancesOfSubstring.swift */,
992+
61538B922B11201900A88846 /* String+Character.swift */,
993+
611191F82B08CC8000D4459B /* Indexer */,
964994
);
965995
path = Documents;
966996
sourceTree = "<group>";
@@ -2102,6 +2132,23 @@
21022132
name = Frameworks;
21032133
sourceTree = "<group>";
21042134
};
2135+
611191F82B08CC8000D4459B /* Indexer */ = {
2136+
isa = PBXGroup;
2137+
children = (
2138+
611191F92B08CC9000D4459B /* SearchIndexer.swift */,
2139+
611191FB2B08CCB800D4459B /* SearchIndexer+AsyncController.swift */,
2140+
611191FF2B08CCD700D4459B /* SearchIndexer+Memory.swift */,
2141+
611191FD2B08CCD200D4459B /* SearchIndexer+File.swift */,
2142+
611192012B08CCDC00D4459B /* SearchIndexer+Search.swift */,
2143+
611192032B08CCED00D4459B /* SearchIndexer+ProgressivSearch.swift */,
2144+
611192052B08CCF600D4459B /* SearchIndexer+Add.swift */,
2145+
611192072B08CCFD00D4459B /* SearchIndexer+Terms.swift */,
2146+
6111920B2B08CD0B00D4459B /* SearchIndexer+InternalMethods.swift */,
2147+
613DF55D2B08DD5D00E9D902 /* FileHelper.swift */,
2148+
);
2149+
path = Indexer;
2150+
sourceTree = "<group>";
2151+
};
21052152
6C092EDC2A53A63E00489202 /* Views */ = {
21062153
isa = PBXGroup;
21072154
children = (
@@ -2995,6 +3042,8 @@
29953042
587B9E8F29301D8F00AC7927 /* BitBucketUserRouter.swift in Sources */,
29963043
B66A4E5129C917D5004573B4 /* AboutWindow.swift in Sources */,
29973044
58F2EB03292FB2B0004A9BDE /* Documentation.docc in Sources */,
3045+
611192042B08CCED00D4459B /* SearchIndexer+ProgressivSearch.swift in Sources */,
3046+
611192022B08CCDC00D4459B /* SearchIndexer+Search.swift in Sources */,
29983047
04BA7C272AE2E9F100584E1C /* GitClient+Push.swift in Sources */,
29993048
2B7A583527E4BA0100D25D4E /* AppDelegate.swift in Sources */,
30003049
D7012EE827E757850001E1EF /* FindNavigatorView.swift in Sources */,
@@ -3046,8 +3095,10 @@
30463095
587B9E8C29301D8F00AC7927 /* GitHubOpenness.swift in Sources */,
30473096
5894E59729FEF7740077E59C /* CEWorkspaceFile+Recursion.swift in Sources */,
30483097
587B9E8229301D8F00AC7927 /* GitHubPreviewHeader.swift in Sources */,
3098+
611191FC2B08CCB800D4459B /* SearchIndexer+AsyncController.swift in Sources */,
30493099
58F2EB02292FB2B0004A9BDE /* Loopable.swift in Sources */,
30503100
6C578D8929CD36E400DC73B2 /* Commands+ForEach.swift in Sources */,
3101+
611192082B08CCFD00D4459B /* SearchIndexer+Terms.swift in Sources */,
30513102
041FC6AA2AE42C9100C1F65A /* SourceControlNavigatorBranchGroupView.swift in Sources */,
30523103
28B8F884280FFE4600596236 /* NSTableView+Background.swift in Sources */,
30533104
6CBA0D512A1BF524002C6FAA /* SegmentedControlImproved.swift in Sources */,
@@ -3070,6 +3121,7 @@
30703121
587B9E7529301D8F00AC7927 /* String+QueryParameters.swift in Sources */,
30713122
58798219292D92370085B254 /* SearchModeModel.swift in Sources */,
30723123
6C5C891B2A3F736500A94FE1 /* FocusedValues.swift in Sources */,
3124+
611192062B08CCF600D4459B /* SearchIndexer+Add.swift in Sources */,
30733125
B62AEDD72A27B3D0009A9F52 /* UtilityAreaTabViewModel.swift in Sources */,
30743126
85773E1E2A3E0A1F00C5D926 /* SettingsSearchResult.swift in Sources */,
30753127
B66A4E4F29C917B8004573B4 /* WelcomeWindow.swift in Sources */,
@@ -3097,6 +3149,8 @@
30973149
581550CF29FBD30400684881 /* StandardTableViewCell.swift in Sources */,
30983150
B62AEDB82A1FE2DC009A9F52 /* UtilityAreaOutputView.swift in Sources */,
30993151
587B9E5C29301D8F00AC7927 /* Parameters.swift in Sources */,
3152+
61538B932B11201900A88846 /* String+Character.swift in Sources */,
3153+
613DF55E2B08DD5D00E9D902 /* FileHelper.swift in Sources */,
31003154
58798235292E30B90085B254 /* FeedbackModel.swift in Sources */,
31013155
04C3255C2801F86900C8DA2D /* ProjectNavigatorMenu.swift in Sources */,
31023156
587B9E6429301D8F00AC7927 /* GitLabCommit.swift in Sources */,
@@ -3110,6 +3164,7 @@
31103164
04BA7C132AE2AA7300584E1C /* GitCheckoutBranchViewModel.swift in Sources */,
31113165
04540D5E27DD08C300E91B77 /* WorkspaceView.swift in Sources */,
31123166
DE6F77872813625500D00A76 /* EditorTabBarDivider.swift in Sources */,
3167+
6111920C2B08CD0B00D4459B /* SearchIndexer+InternalMethods.swift in Sources */,
31133168
6CABB1A129C5593800340467 /* OverlayView.swift in Sources */,
31143169
D7211D4327E066CE008F2ED7 /* Localized+Ex.swift in Sources */,
31153170
581BFB692926431000D251EC /* WelcomeActionView.swift in Sources */,
@@ -3144,6 +3199,7 @@
31443199
285FEC7027FE4B9800E57D53 /* ProjectNavigatorTableViewCell.swift in Sources */,
31453200
6CB9144B29BEC7F100BC47F2 /* (null) in Sources */,
31463201
587B9E7429301D8F00AC7927 /* URL+URLParameters.swift in Sources */,
3202+
61538B902B111FE800A88846 /* String+AppearancesOfSubstring.swift in Sources */,
31473203
6C5BE51C2A3D542B002DA0FC /* FeatureFlagsSettingsView.swift in Sources */,
31483204
581BFB6B2926431000D251EC /* RecentProjectItem.swift in Sources */,
31493205
587FB99029C1246400B519DD /* EditorTabView.swift in Sources */,
@@ -3188,6 +3244,7 @@
31883244
B62AEDB52A1FE295009A9F52 /* UtilityAreaDebugView.swift in Sources */,
31893245
6C049A372A49E2DB00D42923 /* DirectoryEventStream.swift in Sources */,
31903246
04BA7C0E2AE2A76E00584E1C /* SourceControlNavigatorChangesCommitView.swift in Sources */,
3247+
615AA21A2B0CFD480013FCCC /* LazyStringLoader.swift in Sources */,
31913248
6CAAF68A29BC9C2300A1F48A /* (null) in Sources */,
31923249
6C6BD6EF29CD12E900235D17 /* ExtensionManagerWindow.swift in Sources */,
31933250
6CFF967629BEBCD900182D6F /* FileCommands.swift in Sources */,
@@ -3271,6 +3328,7 @@
32713328
587B9E6D29301D8F00AC7927 /* GitLabEventNote.swift in Sources */,
32723329
587B9E9129301D8F00AC7927 /* BitBucketOAuthRouter.swift in Sources */,
32733330
B6E41C7429DD40010088F9F4 /* View+HideSidebarToggle.swift in Sources */,
3331+
611191FA2B08CC9000D4459B /* SearchIndexer.swift in Sources */,
32743332
58822532292C280D00E83CDE /* UtilityAreaViewModel.swift in Sources */,
32753333
043BCF03281DA18A000AC47C /* WorkspaceDocument+Search.swift in Sources */,
32763334
58822527292C280D00E83CDE /* StatusBarIndentSelector.swift in Sources */,
@@ -3290,7 +3348,9 @@
32903348
6C2C155829B4F49100EA60A5 /* SplitViewItem.swift in Sources */,
32913349
6CDA84AD284C1BA000C1CC3A /* EditorTabBarContextMenu.swift in Sources */,
32923350
6C81916729B3E80700B75C92 /* ModifierKeysObserver.swift in Sources */,
3351+
611192002B08CCD700D4459B /* SearchIndexer+Memory.swift in Sources */,
32933352
587B9E8129301D8F00AC7927 /* PublicKey.swift in Sources */,
3353+
611191FE2B08CCD200D4459B /* SearchIndexer+File.swift in Sources */,
32943354
6CB52DC92AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift in Sources */,
32953355
58F2EB0B292FB2B0004A9BDE /* AccountsSettings.swift in Sources */,
32963356
5882252A292C280D00E83CDE /* StatusBarToggleUtilityAreaButton.swift in Sources */,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// FileHelper.swift
3+
// CodeEdit
4+
//
5+
// Created by Tommy Ludwig on 18.11.23.
6+
//
7+
8+
import Foundation
9+
10+
enum FileHelper {
11+
static func urlIsFolder(_ url: URL) -> Bool {
12+
var isDirectory: ObjCBool = false
13+
let exists = FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory)
14+
return exists && isDirectory.boolValue
15+
}
16+
17+
static func urlIsFile(_ url: URL) -> Bool {
18+
var isDirectory: ObjCBool = false
19+
let exists = FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory)
20+
return exists && !isDirectory.boolValue
21+
}
22+
}

0 commit comments

Comments
 (0)