Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Commit

Permalink
CommandBox: extract command text in handleCommandEntered() method
Browse files Browse the repository at this point in the history
Command text is required twice in handleCommandEntered() method, thus,
the TextInputControl#getText() method is called twice.

This hinders readability.

Let's extract the command text at the start of the method, so that
TextInputControl#getText() is not called repeatedly.
  • Loading branch information
bchenghi committed Dec 4, 2020
1 parent 41c98b1 commit 17d9dcb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/seedu/address/ui/CommandBox.java
Expand Up @@ -97,12 +97,13 @@ private void replaceText(String text) {
*/
@FXML
private void handleCommandEntered() {
if (commandTextField.getText().equals("")) {
String commandText = commandTextField.getText();
if (commandText.equals("")) {
return;
}

try {
commandExecutor.execute(commandTextField.getText());
commandExecutor.execute(commandText);
initHistory();
historySnapshot.next();
commandTextField.setText("");
Expand Down

0 comments on commit 17d9dcb

Please sign in to comment.