from prompt_toolkit.buffer import Buffer
from prompt_toolkit.filters import Condition

class CypherBuffer(Buffer):

    def __init__(self, *args, **kwargs):

        @Condition
        def is_multiline():
            text = self.document.text
            return not self.user_wants_out(text)

        super(self.__class__, self).__init__(*args, is_multiline=is_multiline, **kwargs)

    def user_wants_out(self, text):
        return any(
            [
                text.endswith(";"),
                text == "quit",
                text == "exit"
            ]
        )
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.filters import Condition

class CypherBuffer(Buffer):

    def __init__(self, *args, **kwargs):

        @Condition
        def is_multiline():
            text = self.document.text
            return not self.user_wants_out(text)

        super(self.__class__, self).__init__(*args, is_multiline=is_multiline, **kwargs)

    def user_wants_out(self, text):
        return any(
            [
                text.endswith(";"),
                text.endswith("\n"),
                text == "quit",
                text == "exit",
            ]
        )
Allow double return to execute query
Allow double return to execute query

If there’s a double return the text will end with “\n”. Closes #5.

  from prompt_toolkit.buffer import Buffer
  from prompt_toolkit.filters import Condition
  
  class CypherBuffer(Buffer):
  
      def __init__(self, *args, **kwargs):
  
          @Condition
          def is_multiline():
              text = self.document.text
              return not self.user_wants_out(text)
  
          super(self.__class__, self).__init__(*args, is_multiline=is_multiline, **kwargs)
  
      def user_wants_out(self, text):
          return any(
              [
                  text.endswith(";"),
+                 text.endswith("\n"),
                  text == "quit",
-                 text == "exit"
+                 text == "exit",
              ]
          )
Allow double return to execute query
## Code Before:
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.filters import Condition

class CypherBuffer(Buffer):

    def __init__(self, *args, **kwargs):

        @Condition
        def is_multiline():
            text = self.document.text
            return not self.user_wants_out(text)

        super(self.__class__, self).__init__(*args, is_multiline=is_multiline, **kwargs)

    def user_wants_out(self, text):
        return any(
            [
                text.endswith(";"),
                text == "quit",
                text == "exit"
            ]
        )
## Instruction:
Allow double return to execute query
## Code After:
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.filters import Condition

class CypherBuffer(Buffer):

    def __init__(self, *args, **kwargs):

        @Condition
        def is_multiline():
            text = self.document.text
            return not self.user_wants_out(text)

        super(self.__class__, self).__init__(*args, is_multiline=is_multiline, **kwargs)

    def user_wants_out(self, text):
        return any(
            [
                text.endswith(";"),
                text.endswith("\n"),
                text == "quit",
                text == "exit",
            ]
        )