Skip to content

Commit

Permalink
Allow enter key for auto completing
Browse files Browse the repository at this point in the history
  • Loading branch information
nutyworks committed Mar 19, 2024
1 parent 2863aad commit a6d0945
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public abstract class SuggestionWindowMixin {
@Shadow
public abstract void scroll(int offset);

@Shadow
public abstract void complete();

@Inject(at = @At("HEAD"), method = "keyPressed", cancellable = true)
public void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
if ((modifiers & GLFW.GLFW_MOD_CONTROL) > 0 && keyCode == GLFW.GLFW_KEY_N) {
Expand All @@ -33,5 +36,10 @@ public void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoRet
cir.setReturnValue(true);
cir.cancel();
}
if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) {
this.complete();
cir.setReturnValue(true);
cir.cancel();
}
}
}

0 comments on commit a6d0945

Please sign in to comment.