Repository: Qiskit/qiskit

Issue:
bad output for composite gates in text drawer
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**:
- **Python version**:
- **Operating system**:

### What is the current behavior?
When drawing a composite gate on non-adjacent qubits, the text drawer sometimes prints the gate name multiple times.

```python
import numpy
from qiskit import QuantumRegister, QuantumCircuit
from qiskit.quantum_info.operators import Unitary
sigmax = numpy.array([[0, 1], [1, 0]])
sigmay = numpy.array([[0, -1j], [1j, 0]])
xy = Unitary(numpy.kron(sigmax, sigmay))
q = QuantumRegister(5)
circ = QuantumCircuit(q)
circ.append(xy, [q[0], q[3]])
print(circ)
```

```
         ┌─────────┐
q7_0: |0>┤0        ├
         │         │
q7_1: |0>┤ unitary ├
         │ unitary │
q7_2: |0>┤ unitary ├
         │         │
q7_3: |0>┤1        ├
         └─────────┘
q7_4: |0>───────────
                    
```




Discussion:

Resolving patch:
diff --git a/qiskit/visualization/text.py b/qiskit/visualization/text.py
--- a/qiskit/visualization/text.py
+++ b/qiskit/visualization/text.py
@@ -224,6 +224,7 @@ def __init__(self, label, input_length, order, wire_label=''):
         self.top_format = "│{} %s │".format(self.top_pad * len(self.wire_label))
         self.mid_format = "┤{} %s ├".format(self.wire_label)
         self.bot_format = "│{} %s │".format(self.bot_pad * len(self.wire_label))
+        self.top_connect = self.bot_connect = self.mid_content = ''
         self.center_label(input_length, order)
 
 
@@ -262,7 +263,6 @@ class BoxOnClWireMid(MultiBox, BoxOnClWire):
     def __init__(self, label, input_length, order, wire_label=''):
         super().__init__(label)
         self.wire_label = wire_label
-        self.mid_content = label
         self.top_format = "│ %s │"
         self.bot_format = "│ %s │"
         self.top_pad = self.bot_pad = ' '


Test patch:
diff --git a/test/python/visualization/test_circuit_text_drawer.py b/test/python/visualization/test_circuit_text_drawer.py
--- a/test/python/visualization/test_circuit_text_drawer.py
+++ b/test/python/visualization/test_circuit_text_drawer.py
@@ -17,6 +17,7 @@
 from qiskit.visualization.circuit_visualization import \
     _text_circuit_drawer
 from qiskit.test import QiskitTestCase
+from qiskit.circuit import Gate
 
 
 class TestTextDrawerElement(QiskitTestCase):
@@ -850,5 +851,97 @@ def test_text_justify_right_measure_resize(self):
         self.assertEqual(str(_text_circuit_drawer(circuit, justify='right')), expected)
 
 
+class TestTextDrawerMultiQGates(QiskitTestCase):
+    """ Gates impling multiple qubits."""
+
+    def test_2Qgate(self):
+        """ 2Q no params. """
+        expected = '\n'.join(["        ┌───────┐",
+                              "q_1: |0>┤1      ├",
+                              "        │  twoQ │",
+                              "q_0: |0>┤0      ├",
+                              "        └───────┘"])
+
+        qr = QuantumRegister(2, 'q')
+        circuit = QuantumCircuit(qr)
+
+        my_gate2 = Gate(name='twoQ', num_qubits=2, params=[])
+        circuit.append(my_gate2, [qr[0], qr[1]])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit, reverse_bits=True)), expected)
+
+    def test_2Qgate_cross_wires(self):
+        """ 2Q no params, with cross wires """
+        expected = '\n'.join(["        ┌───────┐",
+                              "q_1: |0>┤0      ├",
+                              "        │  twoQ │",
+                              "q_0: |0>┤1      ├",
+                              "        └───────┘"])
+
+        qr = QuantumRegister(2, 'q')
+        circuit = QuantumCircuit(qr)
+
+        my_gate2 = Gate(name='twoQ', num_qubits=2, params=[])
+        circuit.append(my_gate2, [qr[1], qr[0]])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit, reverse_bits=True)), expected)
+
+    def test_3Qgate_cross_wires(self):
+        """ 3Q no params, with cross wires """
+        expected = '\n'.join(["        ┌─────────┐",
+                              "q_2: |0>┤1        ├",
+                              "        │         │",
+                              "q_1: |0>┤0 threeQ ├",
+                              "        │         │",
+                              "q_0: |0>┤2        ├",
+                              "        └─────────┘"])
+
+        qr = QuantumRegister(3, 'q')
+        circuit = QuantumCircuit(qr)
+
+        my_gate3 = Gate(name='threeQ', num_qubits=3, params=[])
+        circuit.append(my_gate3, [qr[1], qr[2], qr[0]])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit, reverse_bits=True)), expected)
+
+    def test_2Qgate_nottogether(self):
+        """ 2Q that are not together """
+        expected = '\n'.join(["        ┌──────┐",
+                              "q_2: |0>┤1     ├",
+                              "        │      │",
+                              "q_1: |0>┤ twoQ ├",
+                              "        │      │",
+                              "q_0: |0>┤0     ├",
+                              "        └──────┘"])
+
+        qr = QuantumRegister(3, 'q')
+        circuit = QuantumCircuit(qr)
+
+        my_gate2 = Gate(name='twoQ', num_qubits=2, params=[])
+        circuit.append(my_gate2, [qr[0], qr[2]])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit, reverse_bits=True)), expected)
+
+    def test_2Qgate_nottogether_across_4(self):
+        """ 2Q that are 2 bits apart"""
+        expected = '\n'.join(["        ┌──────┐",
+                              "q_3: |0>┤1     ├",
+                              "        │      │",
+                              "q_2: |0>┤      ├",
+                              "        │ twoQ │",
+                              "q_1: |0>┤      ├",
+                              "        │      │",
+                              "q_0: |0>┤0     ├",
+                              "        └──────┘"])
+
+        qr = QuantumRegister(4, 'q')
+        circuit = QuantumCircuit(qr)
+
+        my_gate2 = Gate(name='twoQ', num_qubits=2, params=[])
+        circuit.append(my_gate2, [qr[0], qr[3]])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit, reverse_bits=True)), expected)
+
+
 if __name__ == '__main__':
     unittest.main()