]> git.proxmox.com Git - mirror_xterm.js.git/blobdiff - src/SelectionManager.test.ts
Merge pull request #746 from Tyriar/745_colon_word_sep
[mirror_xterm.js.git] / src / SelectionManager.test.ts
index 4de1d1cf814e16101479d1c3da61065be7b05a5d..0fe674378fc7df822fc94e0346c6a17385cec3b4 100644 (file)
@@ -143,39 +143,39 @@ describe('SelectionManager', () => {
       assert.equal(selectionManager.selectionText, 'foo');
     });
     it('should select up to non-path characters that are commonly adjacent to paths', () => {
-      buffer.push(stringToRow(':ab:(cd)[ef]{gh}'));
+      buffer.push(stringToRow('(cd)[ef]{gh}\'ij"'));
       selectionManager.selectWordAt([0, 0]);
-      assert.equal(selectionManager.selectionText, ':ab');
+      assert.equal(selectionManager.selectionText, '(cd');
       selectionManager.selectWordAt([1, 0]);
-      assert.equal(selectionManager.selectionText, 'ab');
+      assert.equal(selectionManager.selectionText, 'cd');
       selectionManager.selectWordAt([2, 0]);
-      assert.equal(selectionManager.selectionText, 'ab');
+      assert.equal(selectionManager.selectionText, 'cd');
       selectionManager.selectWordAt([3, 0]);
-      assert.equal(selectionManager.selectionText, 'ab:');
+      assert.equal(selectionManager.selectionText, 'cd)');
       selectionManager.selectWordAt([4, 0]);
-      assert.equal(selectionManager.selectionText, '(cd');
+      assert.equal(selectionManager.selectionText, '[ef');
       selectionManager.selectWordAt([5, 0]);
-      assert.equal(selectionManager.selectionText, 'cd');
+      assert.equal(selectionManager.selectionText, 'ef');
       selectionManager.selectWordAt([6, 0]);
-      assert.equal(selectionManager.selectionText, 'cd');
+      assert.equal(selectionManager.selectionText, 'ef');
       selectionManager.selectWordAt([7, 0]);
-      assert.equal(selectionManager.selectionText, 'cd)');
+      assert.equal(selectionManager.selectionText, 'ef]');
       selectionManager.selectWordAt([8, 0]);
-      assert.equal(selectionManager.selectionText, '[ef');
+      assert.equal(selectionManager.selectionText, '{gh');
       selectionManager.selectWordAt([9, 0]);
-      assert.equal(selectionManager.selectionText, 'ef');
+      assert.equal(selectionManager.selectionText, 'gh');
       selectionManager.selectWordAt([10, 0]);
-      assert.equal(selectionManager.selectionText, 'ef');
+      assert.equal(selectionManager.selectionText, 'gh');
       selectionManager.selectWordAt([11, 0]);
-      assert.equal(selectionManager.selectionText, 'ef]');
+      assert.equal(selectionManager.selectionText, 'gh}');
       selectionManager.selectWordAt([12, 0]);
-      assert.equal(selectionManager.selectionText, '{gh');
+      assert.equal(selectionManager.selectionText, '\'ij');
       selectionManager.selectWordAt([13, 0]);
-      assert.equal(selectionManager.selectionText, 'gh');
+      assert.equal(selectionManager.selectionText, 'ij');
       selectionManager.selectWordAt([14, 0]);
-      assert.equal(selectionManager.selectionText, 'gh');
+      assert.equal(selectionManager.selectionText, 'ij');
       selectionManager.selectWordAt([15, 0]);
-      assert.equal(selectionManager.selectionText, 'gh}');
+      assert.equal(selectionManager.selectionText, 'ij"');
     });
   });
 
@@ -201,4 +201,20 @@ describe('SelectionManager', () => {
       assert.equal(selectionManager.selectionText, '1\n2\n3\n4\n5');
     });
   });
+
+  describe('hasSelection', () => {
+    it('should return whether there is a selection', () => {
+      selectionManager.model.selectionStart = [0, 0];
+      selectionManager.model.selectionStartLength = 0;
+      assert.equal(selectionManager.hasSelection, false);
+      selectionManager.model.selectionEnd = [0, 0];
+      assert.equal(selectionManager.hasSelection, false);
+      selectionManager.model.selectionEnd = [1, 0];
+      assert.equal(selectionManager.hasSelection, true);
+      selectionManager.model.selectionEnd = [0, 1];
+      assert.equal(selectionManager.hasSelection, true);
+      selectionManager.model.selectionEnd = [1, 1];
+      assert.equal(selectionManager.hasSelection, true);
+    });
+  });
 });