Fix a bug in LineReader for recognizing command
diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt
index 33d10e3..03c5408 100644
--- a/cli/CMakeLists.txt
+++ b/cli/CMakeLists.txt
@@ -189,10 +189,12 @@
 endif()
 if(USE_LINENOISE)
   target_link_libraries(quickstep_cli_LineReader
+                        glog
                         linenoise
                         quickstep_utility_Macros)
 else()
   target_link_libraries(quickstep_cli_LineReader
+                        glog
                         quickstep_utility_Macros)
 endif()
 target_link_libraries(quickstep_cli_LineReaderBuffered
diff --git a/cli/LineReader.cpp b/cli/LineReader.cpp
index 002727d..1a23dd3 100644
--- a/cli/LineReader.cpp
+++ b/cli/LineReader.cpp
@@ -23,6 +23,8 @@
 #include <cctype>
 #include <string>
 
+#include "glog/logging.h"
+
 using std::ispunct;
 using std::size_t;
 using std::string;
@@ -171,7 +173,7 @@
             case '.':
             case '\\':  //  Fall Through.
               // If the dot or forward slash begins the line, begin a command search.
-              if (scan_position == 0) {
+              if (special_char_location == multiline_buffer.find_first_not_of(" \t\r\n")) {
                 line_state = kCommand;
               } else {
                 // This is a regular character, so skip over it.
@@ -217,7 +219,12 @@
             if (std::all_of(leftover_.begin(), leftover_.end(), ::isspace)) {
               leftover_.clear();
             }
-            return multiline_buffer.substr(0, special_char_location + 1);
+            // Skip all the whitespaces before the command.
+            const std::size_t start_position =
+                multiline_buffer.find_first_not_of(" \t\r\n");
+            DCHECK_LT(start_position, special_char_location + 1);
+            return multiline_buffer.substr(start_position,
+                                           special_char_location + 1 - start_position);
           }
           break;
       }
diff --git a/cli/tests/command_executor/D.test b/cli/tests/command_executor/D.test
index 36e9a92..c3564a6 100644
--- a/cli/tests/command_executor/D.test
+++ b/cli/tests/command_executor/D.test
@@ -58,6 +58,8 @@
 INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
 --
 ==
+
+
 \d foo
 --
  Table "foo"
@@ -69,6 +71,7 @@
  col4   | Float  
  col5   | Char(5)
 ==
+
 \d foo2
 --
  Table "foo2"
@@ -80,6 +83,7 @@
  col4                           | Float  
  averyverylongcolumnnamefortest | Char(5)
 ==
+
 \d foo3
 --
  Table "foo3"
@@ -93,6 +97,7 @@
  Indexes
   "foo3_index_1" CSB_TREE (col1)
 ==
+
 \d foo4
 --
  Table "foo4"
@@ -107,6 +112,7 @@
   "foo4_index_2" CSB_TREE (col3, col4)
   "foo4_index_1" CSB_TREE (col1, col2)
 ==
+
 \d foo_hash_part
 --
  Table "foo_hash_part"
@@ -118,6 +124,7 @@
   PARTITION BY HASH ( col1 ) PARTITIONS 4
   | 1 | 1 | 1 | 1 |
 ==
+
 \d
 --
        List of relations
@@ -132,6 +139,22 @@
  averylongtablenamethatseemstoneverend | table | 1      
 
 ==
+
+\d
+--
+       List of relations
+
+ Name                                  | Type  | Blocks 
++--------------------------------------+-------+---------+
+ foo                                   | table | 1      
+ foo2                                  | table | 1      
+ foo3                                  | table | 1      
+ foo4                                  | table | 0      
+ foo_hash_part                         | table | 4      
+ averylongtablenamethatseemstoneverend | table | 1      
+
+==
+
 \d invalidtable
 --
 ERROR:  Unrecognized relation invalidtable (1 : 4)
diff --git a/cli/tests/command_executor/Dt.test b/cli/tests/command_executor/Dt.test
index 8d81029..022cae6 100644
--- a/cli/tests/command_executor/Dt.test
+++ b/cli/tests/command_executor/Dt.test
@@ -50,6 +50,8 @@
 INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
 --
 ==
+
+
 \dt
 --
        List of relations
@@ -63,6 +65,7 @@
  averylongtablenamethatseemstoneverend | table | 1      
 
 ==
+
 \dt foo
 --
        List of relations
@@ -72,6 +75,7 @@
  foo    | table | 1      
 
 ==
+
 \dt invalidtable
 --
 ERROR:  Unrecognized relation invalidtable (1 : 5)