Fix key selection for build level keys
Fix key selection for build level keys

PR #2469 added build keys to tab completion, with the side effect of
considering as available candidate in key selection, thus making sbt
think that some inputs were ambiguous (e.g. `baseDirectory`): should it
apply to the current project or to the build level key?

This commit fixes this issue by improving the key selection:
 - If there's no candidate, we return the default key
 - If there's a single possible project level key, and zero or more
   build level keys, then we select the project level key.
 - If there are zero project level key, and a single build level key,
   then we select the build level key
 - If there are multiple candidates, sbt says that the input is
   ambiguous.

Fixes #2707

sbt/sbt,Duhemm/sbt,mdedetrich/sbt,sbt/sbt,mdedetrich/sbt,xuwei-k/xsbt,xuwei-k/xsbt,mdedetrich/sbt,sbt/sbt,sbt/sbt,xuwei-k/xsbt,mdedetrich/sbt,Duhemm/sbt,sbt/sbt,xuwei-k/xsbt,sbt/sbt,sbt/sbt,mdedetrich/sbt,xuwei-k/xsbt,mdedetrich/sbt,mdedetrich/sbt