Skip to content

Commit

Permalink
fix(plugins/plugin-kubectl): kubectl tab completion does not let me t…
Browse files Browse the repository at this point in the history
…ab-complete some filepaths

Fixes #5413
  • Loading branch information
starpit committed Aug 20, 2020
1 parent 5e92cd7 commit f461b8b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/plugin-kubectl/src/lib/tab-completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ async function completeResourceNames(tab: Tab, commandLine: CommandLine, spec: T
const { argvNoOptions, argv, parsedOptions } = commandLine
const command = getCommandFromArgs({ argvNoOptions })

const verb = argvNoOptions[1]

// index of the arg just before the one to be completed
const previous = spec.toBeCompletedIdx === -1 ? commandLine.argv.length - 1 : spec.toBeCompletedIdx - 1
const verb = argvNoOptions[1]

if (previous > 0 && (argv[previous] === '-n' || argv[previous] === '--namespace')) {
//
// then we are being asked to complete a namespace
Expand All @@ -70,6 +70,7 @@ async function completeResourceNames(tab: Tab, commandLine: CommandLine, spec: T
return getMatchingStrings(tab, cmd, spec)
} else if (
(argvNoOptions[0] === 'kubectl' || argvNoOptions[0] === 'k' || argvNoOptions[0] === 'oc') &&
!/^-/.test(argv[previous]) &&
(verb === 'get' ||
verb === 'annotate' ||
verb === 'describe' ||
Expand Down

0 comments on commit f461b8b

Please sign in to comment.