Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProB 2 Jupyter Kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
ProB 2 Jupyter Kernel
Commits
dda24329
Commit
dda24329
authored
4 years ago
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Fix completion not working if no arguments have been typed yet
parent
d5d26190
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/prob2/jupyter/ProBKernel.java
+25
-10
25 additions, 10 deletions
src/main/java/de/prob2/jupyter/ProBKernel.java
with
25 additions
and
10 deletions
src/main/java/de/prob2/jupyter/ProBKernel.java
+
25
−
10
View file @
dda24329
...
...
@@ -472,17 +472,32 @@ public final class ProBKernel extends BaseKernel {
private
static
@Nullable
ReplacementOptions
completeCommandArguments
(
final
@NotNull
Command
command
,
final
@NotNull
PositionedString
argString
,
final
int
at
)
{
final
SplitResult
split
=
CommandUtils
.
splitArgs
(
command
.
getParameters
(),
argString
,
at
);
final
Parameter
<?>
parameterToComplete
;
final
PositionedString
argumentToComplete
;
if
(
split
.
getParameterAtPosition
().
isPresent
())
{
final
Optional
<
Completer
>
completer
=
command
.
getParameterCompleters
().
getCompleterForParameter
(
split
.
getParameterAtPosition
().
get
());
if
(
completer
.
isPresent
())
{
final
List
<
PositionedString
>
argsAtPosition
=
split
.
getArguments
().
get
(
split
.
getParameterAtPosition
().
get
());
// If any arguments were split,
// use the last parameter for completion.
parameterToComplete
=
split
.
getParameterAtPosition
().
get
();
final
List
<
PositionedString
>
argsAtPosition
=
split
.
getArguments
().
get
(
parameterToComplete
);
assert
!
argsAtPosition
.
isEmpty
();
final
PositionedString
lastArgument
=
argsAtPosition
.
get
(
argsAtPosition
.
size
()
-
1
);
final
ReplacementOptions
replacements
=
completer
.
get
().
complete
(
lastArgument
.
getValue
(),
at
-
lastArgument
.
getStartPosition
());
return
replacements
==
null
?
null
:
offsetReplacementOptions
(
replacements
,
lastArgument
.
getStartPosition
());
argumentToComplete
=
argsAtPosition
.
get
(
argsAtPosition
.
size
()
-
1
);
}
else
if
(!
command
.
getParameters
().
getPositionalParameters
().
isEmpty
())
{
// Special case: if the command has parameters,
// but argument splitting stopped before any arguments were split,
// perform completion on the first parameter and an empty string at the cursor.
parameterToComplete
=
command
.
getParameters
().
getPositionalParameters
().
get
(
0
);
argumentToComplete
=
new
PositionedString
(
""
,
at
);
}
else
{
// Command has no parameters,
// so completion in the arguments is not possible.
return
null
;
}
final
Optional
<
Completer
>
completer
=
command
.
getParameterCompleters
().
getCompleterForParameter
(
parameterToComplete
);
if
(
completer
.
isPresent
())
{
final
ReplacementOptions
replacements
=
completer
.
get
().
complete
(
argumentToComplete
.
getValue
(),
at
-
argumentToComplete
.
getStartPosition
());
return
replacements
==
null
?
null
:
offsetReplacementOptions
(
replacements
,
argumentToComplete
.
getStartPosition
());
}
else
{
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment