diff options
Diffstat (limited to 'src/server/workspace_symbols.odin')
| -rw-r--r-- | src/server/workspace_symbols.odin | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/server/workspace_symbols.odin b/src/server/workspace_symbols.odin index 11e7a8a..b6f42c8 100644 --- a/src/server/workspace_symbols.odin +++ b/src/server/workspace_symbols.odin @@ -1,7 +1,6 @@ package server import "core:fmt" -import "core:log" import "core:os" import "core:path/filepath" import "core:strings" @@ -19,25 +18,6 @@ WorkspaceCache :: struct { @(thread_local, private = "file") cache: WorkspaceCache -@(private) -walk_dir :: proc(info: os.File_Info, in_err: os.Errno, user_data: rawptr) -> (err: os.Error, skip_dir: bool) { - pkgs := cast(^[dynamic]string)user_data - - if info.is_dir { - dir, _ := filepath.to_slash(info.fullpath, context.temp_allocator) - dir_name := filepath.base(dir) - - for blacklist in dir_blacklist { - if blacklist == dir_name { - return nil, true - } - } - append(pkgs, dir) - } - - return nil, false -} - get_workspace_symbols :: proc(query: string) -> (workspace_symbols: []WorkspaceSymbol, ok: bool) { if time.since(cache.time) > 20 * time.Second { for pkg in cache.pkgs { @@ -48,7 +28,23 @@ get_workspace_symbols :: proc(query: string) -> (workspace_symbols: []WorkspaceS uri := common.parse_uri(workspace.uri, context.temp_allocator) or_return pkgs := make([dynamic]string, 0, context.temp_allocator) - filepath.walk(uri.path, walk_dir, &pkgs) + w := os.walker_create(uri.path) + for info in os.walker_walk(&w) { + if info.type == .Directory { + dir := filepath.dir(info.fullpath, context.temp_allocator) + dir_name := filepath.base(dir) + found := false + for blacklist in dir_blacklist { + if blacklist == dir_name { + found = true + break + } + } + if !found { + append(&pkgs, dir) + } + } + } _pkg: for pkg in pkgs { matches, err := filepath.glob(fmt.tprintf("%v/*.odin", pkg), context.temp_allocator) @@ -58,7 +54,7 @@ get_workspace_symbols :: proc(query: string) -> (workspace_symbols: []WorkspaceS } for exclude_path in common.config.profile.exclude_path { - exclude_forward, _ := filepath.to_slash(exclude_path, context.temp_allocator) + exclude_forward, _ := filepath.replace_path_separators(exclude_path, '/', context.temp_allocator) if exclude_forward[len(exclude_forward) - 2:] == "**" { lower_pkg := strings.to_lower(pkg) |