Skip to content

Commit 55d0e07

Browse files
akinomyogascop
authored andcommitted
fix(java): fix a bug of assigning results in cur but not COMPREPLY
At the end of the function `_java_packages', `cur` was modified to be the list of package names with separators `/` being replaced with periods `.`. It does not seem to make sense, and the value is actually not used after the call of `_java_packages'. Historically, this line was introduced in commit ff01750. This seems to be a reuse of another similar line in `_java_classes` where the result is assigned to the array `COMPREPLY` but not to `cur`. This makes a more sense. In fact, the man page of the `javadoc` command [1] mentions an example of the package specification, where the package names have the form of `xxx.yyy.zzz` but not `xxx/yyy/zzz`. [1] https://docs.oracle.com/javase/9/javadoc/javadoc-command.htm Here, we assume that the original intent of the line in ff01750 was to convert the generated package names to have `xxx.yyy.zzz`, i.e., wanted to assign the results to the array `COMPREPLY` but not to `cur`. This commit implements the original intent.
1 parent c2240bc commit 55d0e07

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

completions/java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ _comp_cmd_java__packages()
128128
# keep only packages with the package suffix `/` being removed
129129
_comp_split -l COMPREPLY "$(printf '%s\n' "${COMPREPLY[@]}" | command sed -n 's,/$,,p')"
130130
# convert path syntax to package syntax
131-
cur="${COMPREPLY[*]//\//.}"
131+
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]//\//.}")
132132
fi
133133
}
134134

0 commit comments

Comments
 (0)