 helpers = require './spec-helper'
 
-describe "TextObjects", ->
+_ = require 'underscore-plus'
+
+fdescribe "TextObjects", ->
   [editor, editorElement, vimState] = []
 
   beforeEach ->


  describe "the 'i{' text object", ->
    beforeEach ->
      text "{ something in here and in {here} }"
      cursor [0, 9]

    it "applies operators inside the current word in operator-pending mode", ->
      ensureKeystroke 'di{',
        text: "{}"
        cursor: [0, 1]

    it "applies operators inside the current word in operator-pending mode (second test)", ->
      cursor [0, 29]
      ensureKeystroke 'di{',
        text: "{ something in here and in {} }"
        cursor: [0, 28]

  describe "the 'i<' text object", ->
    beforeEach ->
      text "< something in here and in <here> >"
      cursor [0, 9]

    it "applies operators inside the current word in operator-pending mode", ->
      ensureKeystroke 'di<',
        text: "<>"
        cursor: [0, 1]

    it "applies operators inside the current word in operator-pending mode (second test)", ->
      cursor [0, 29]
      ensureKeystroke 'di<',
        text: "< something in here and in <> >"
        cursor: [0, 28]

  describe "the 'it' text object", ->
    beforeEach ->
      text "<something>here</something><again>"
      cursor [0, 5]

    it "applies only if in the value of a tag", ->
      ensureKeystroke 'dit',
        text: "<something></something><again>"
        cursor: [0, 11]

    it "applies operators inside the current word in operator-pending mode", ->
      cursor [0, 13]
      ensureKeystroke 'dit',
        text: "<something></something><again>"
        cursor: [0, 11]

  describe "the 'ip' text object", ->
    beforeEach ->
      text "\nParagraph-1\nParagraph-1\nParagraph-1\n\n"
      cursor [2, 2]

    it "applies operators inside the current paragraph in operator-pending mode", ->
      ensureKeystroke 'yip',
        text: "\nParagraph-1\nParagraph-1\nParagraph-1\n\n"
        cursor: [1, 0]
        register: "Paragraph-1\nParagraph-1\nParagraph-1\n"

    it "selects inside the current paragraph in visual mode", ->
      ensureKeystroke 'vip',
        selectedScreenRange: [[1, 0], [4, 0]]

  describe "the 'ap' text object", ->
    beforeEach ->
      text "text\n\nParagraph-1\nParagraph-1\nParagraph-1\n\nmoretext"
      cursor [3, 2]

    it "applies operators around the current paragraph in operator-pending mode", ->
      ensureKeystroke 'yap',
        text: "text\n\nParagraph-1\nParagraph-1\nParagraph-1\n\nmoretext"
        cursor: [2, 0]
        register: "Paragraph-1\nParagraph-1\nParagraph-1\n\n"

    it "selects around the current paragraph in visual mode", ->
      ensureKeystroke 'vap',
        selectedScreenRange: [[2, 0], [6, 0]]

  describe "the 'i[' text object", ->
    beforeEach ->
      text "[ something in here and in [here] ]"
      cursor [0, 9]

    it "applies operators inside the current word in operator-pending mode", ->
      ensureKeystroke 'di[',
        text: "[]"
        cursor: [0, 1]

    it "applies operators inside the current word in operator-pending mode (second test)", ->
      cursor [0, 29]
      ensureKeystroke 'di[',
        text: "[ something in here and in [] ]"
        cursor: [0, 28]

  describe "the 'i\'' text object", ->
    beforeEach ->
      text "' something in here and in 'here' ' and over here"
      cursor [0, 9]

    it "applies operators inside the current string in operator-pending mode", ->
      ensureKeystroke "di'",
        text: "''here' ' and over here"
        cursor: [0, 1]



  describe "the 'iW' text object", ->
    beforeEach ->
      set
        text: "12(45 ab'de ABCDE"
        cursor: [0, 9]

    it "applies operators inside the current whole word in operator-pending mode", ->
      ensure 'diW',
        text:     "12(45  ABCDE"
        cursor:   [0, 6]
        register: "ab'de"

    it "selects inside the current whole word in visual mode", ->
      ensure 'viW',
        selectedScreenRange: [[0, 6], [0, 11]]

  describe "the 'i(' text object", ->
    beforeEach ->
      set
        text: "( something in here and in (here) )"
        cursor: [0, 9]

    it "applies operators inside the current word in operator-pending mode", ->
      ensure 'di(',
        text: "()"
        cursor: [0, 1]

    it "applies operators inside the current word in operator-pending mode (second test)", ->
      set
        cursor: [0, 29]
      ensure 'di(',
        text: "( something in here and in () )"
        cursor: [0, 28]

    it "works with multiple cursors", ->
      set
        text: "( a b ) cde ( f g h ) ijk"
        cursor: [0, 2]
        addCursor: [0, 18]
      ensure 'vi(',
        selectedBufferRanges: [
          [[0, 1],  [0, 6]]
          [[0, 13], [0, 20]]
