                         emptyListItem = lastLine.match /^(\s*\* )$/
 
                         if emptyListItem
-                            markdownCaretPositon = removeEmptyLine(data.textarea, lines.length - 1, data.caretPosition)
+                            markdownCaretPositon = addLine(data.textarea, cursorLine - 1)
                         else
-                            breakLineAtBeginning = newLineContent.match /^(\s*)\*\s/
-
-                            if !breakLineAtBeginning
-                                return "\n#{match[1]}" if match
+                            markdownCaretPositon = addLine(data.textarea, cursorLine, "#{match[1]}")
 
                     # ordered list
                     match = lastLine.match /^(\s*)(\d+)\.\s/

                        emptyListItem = lastLine.match /^(\s*)\-\s$/

                        if emptyListItem
                            markdownCaretPositon = removeEmptyLine(data.textarea, lines.length - 1, data.caretPosition)
                        else
                            breakLineAtBeginning = newLineContent.match /^(\s*)\-\s/

                            if !breakLineAtBeginning
                                return "\n#{match[1]}" if match

                    # unordered list *
                    match = lastLine.match /^(\s*\* ).*/


module = angular.module("taigaCommon")

# How to test lists (-, *, 1.)
# test it with text after & before the list
# + is the cursor position

# CASE 1
# - aa+
# --> enter
# - aa
# - +

# CASE 1
# - +
# --> enter

# +

# CASE 3
# - bb+cc
# --> enter
# - bb
# - cc

# CASE 3
# +- aa
# --> enter

# - aa

#############################################################################
## WYSIWYG markitup editor directive
