(prefix string, onlyDirs bool)
| 338 | } |
| 339 | |
| 340 | func (c *shellAutoCompleter) completeRemotePath(prefix string, onlyDirs bool) ([][]rune, int) { |
| 341 | currentPath := c.currentPath() |
| 342 | targetPath := resolveShellPath(currentPath, prefix) |
| 343 | basePrefix := prefix |
| 344 | if strings.TrimSpace(prefix) == "" { |
| 345 | targetPath = currentPath |
| 346 | basePrefix = "" |
| 347 | } |
| 348 | |
| 349 | parentPath := targetPath |
| 350 | namePrefix := "" |
| 351 | if prefix != "" && !strings.HasSuffix(prefix, "/") { |
| 352 | parentPath = path.Dir(targetPath) |
| 353 | if parentPath == "." { |
| 354 | parentPath = "/" |
| 355 | } |
| 356 | namePrefix = path.Base(targetPath) |
| 357 | } |
| 358 | |
| 359 | parentID := "" |
| 360 | var err error |
| 361 | if parentPath != "/" { |
| 362 | parentID, err = c.fileStatSource.GetPathFolderId(parentPath) |
| 363 | if err != nil { |
| 364 | return nil, len([]rune(basePrefix)) |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | files, err := c.fileStatSource.GetFolderFileStatList(parentID) |
| 369 | if err != nil { |
| 370 | return nil, len([]rune(basePrefix)) |
| 371 | } |
| 372 | |
| 373 | candidates := make([]string, 0) |
| 374 | for _, file := range files { |
| 375 | if onlyDirs && file.Kind != api.FileKindFolder { |
| 376 | continue |
| 377 | } |
| 378 | if !strings.HasPrefix(file.Name, namePrefix) { |
| 379 | continue |
| 380 | } |
| 381 | |
| 382 | remaining := file.Name[len(namePrefix):] |
| 383 | if file.Kind == api.FileKindFolder { |
| 384 | remaining += "/" |
| 385 | } |
| 386 | candidates = append(candidates, escapeShellCompletion(remaining)) |
| 387 | } |
| 388 | |
| 389 | return toRuneCandidates(candidates), len([]rune(basePrefix)) |
| 390 | } |
| 391 | |
| 392 | func completeLocalPath(prefix string, onlyDirs bool) ([][]rune, int) { |
| 393 | expandedPrefix := utils.ExpandLocalPath(prefix) |
no test coverage detected