* Determine completion type based solely on prefix characteristics
(prefix: string)
| 36 | * Determine completion type based solely on prefix characteristics |
| 37 | */ |
| 38 | function getCompletionTypeFromPrefix(prefix: string): ShellCompletionType { |
| 39 | if (prefix.startsWith('$')) { |
| 40 | return 'variable' |
| 41 | } |
| 42 | if ( |
| 43 | prefix.includes('/') || |
| 44 | prefix.startsWith('~') || |
| 45 | prefix.startsWith('.') |
| 46 | ) { |
| 47 | return 'file' |
| 48 | } |
| 49 | return 'command' |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Find the last string token and its index in parsed tokens |