+ * Subclasses overriding this method should ensure that the following conditions are met: + *
+ *null if there is no result.
+ *
+ * @implSpec
+ * Implementations should call {@code super.execute(event)} at the end to delegate the actual movement.
+ */
+ @Override
+ public Object execute(final ExecutionEvent event) {
+ QInvocationSession qInvocationSessionInstance = QInvocationSession.getInstance();
+
+ switch (direction) {
+ case FORWARD:
+ qInvocationSessionInstance.incrementCurentSuggestionIndex();
+ break;
+ case BACKWARD:
+ qInvocationSessionInstance.decrementCurrentSuggestionIndex();
+ break;
+ default:
+ qInvocationSessionInstance.incrementCurentSuggestionIndex();
+ }
+
+ return null;
+ }
+
+ protected final void setCommandDirection(final Direction direction) {
+ this.direction = direction;
+ }
+}
diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/handlers/QToggleSuggestionsBackwardHandler.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/handlers/QToggleSuggestionsBackwardHandler.java
new file mode 100644
index 000000000..a284c78b9
--- /dev/null
+++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/handlers/QToggleSuggestionsBackwardHandler.java
@@ -0,0 +1,15 @@
+// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+
+package software.aws.toolkits.eclipse.amazonq.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+
+public class QToggleSuggestionsBackwardHandler extends AbstractQToggleSuggestionsHandler {
+ // Actual command handler logic consolidated in parent class
+ @Override
+ public final Object execute(final ExecutionEvent event) {
+ super.setCommandDirection(Direction.BACKWARD);
+
+ return super.execute(event);
+ }
+}
diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/handlers/QToggleSuggestionsForwardHandler.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/handlers/QToggleSuggestionsForwardHandler.java
new file mode 100644
index 000000000..3a9922057
--- /dev/null
+++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/handlers/QToggleSuggestionsForwardHandler.java
@@ -0,0 +1,15 @@
+// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+
+package software.aws.toolkits.eclipse.amazonq.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+
+public class QToggleSuggestionsForwardHandler extends AbstractQToggleSuggestionsHandler {
+ // Actual command handler logic consolidated in parent class
+ @Override
+ public final Object execute(final ExecutionEvent event) {
+ super.setCommandDirection(Direction.FORWARD);
+
+ return super.execute(event);
+ }
+}
diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/QInlineVerifyKeyListener.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/QInlineVerifyKeyListener.java
index 77e847790..5f5484e8a 100644
--- a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/QInlineVerifyKeyListener.java
+++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/QInlineVerifyKeyListener.java
@@ -46,6 +46,8 @@ public void verifyKey(final VerifyEvent event) {
// Here we conduct typeahead logic
String currentSuggestion = qInvocationSessionInstance.getCurrentSuggestion().trim();
int currentOffset = widget.getCaretOffset();
+ qInvocationSessionInstance
+ .setHasBeenTypedahead(currentOffset - qInvocationSessionInstance.getInvocationOffset() > 0);
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode("org.eclipse.jdt.ui");
// This needs to be defaulted to true. This key is only present in the
// preference store if it is set to false.
@@ -162,7 +164,6 @@ public void verifyKey(final VerifyEvent event) {
break;
}
}
-
leadingWhitespaceSkipped += newWs;
qInvocationSessionInstance.setLeadingWhitespaceSkipped(leadingWhitespaceSkipped);
}
diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/QInvocationSession.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/QInvocationSession.java
index 4270fdea1..9de065f37 100644
--- a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/QInvocationSession.java
+++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/QInvocationSession.java
@@ -46,6 +46,7 @@ public final class QInvocationSession extends QResource {
private Stack