]> git.proxmox.com Git - mirror_xterm.js.git/blobdiff - src/SelectionManager.test.ts
Merge pull request #733 from Tyriar/732_drop_selection_on_alt
[mirror_xterm.js.git] / src / SelectionManager.test.ts
index 4de1d1cf814e16101479d1c3da61065be7b05a5d..dcc9cb5a9cf80074912da81029bb7f7fd0d97638 100644 (file)
@@ -143,7 +143,7 @@ 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(':ab:(cd)[ef]{gh}\'ij"'));
       selectionManager.selectWordAt([0, 0]);
       assert.equal(selectionManager.selectionText, ':ab');
       selectionManager.selectWordAt([1, 0]);
@@ -176,6 +176,14 @@ describe('SelectionManager', () => {
       assert.equal(selectionManager.selectionText, 'gh');
       selectionManager.selectWordAt([15, 0]);
       assert.equal(selectionManager.selectionText, 'gh}');
+      selectionManager.selectWordAt([16, 0]);
+      assert.equal(selectionManager.selectionText, '\'ij');
+      selectionManager.selectWordAt([17, 0]);
+      assert.equal(selectionManager.selectionText, 'ij');
+      selectionManager.selectWordAt([18, 0]);
+      assert.equal(selectionManager.selectionText, 'ij');
+      selectionManager.selectWordAt([19, 0]);
+      assert.equal(selectionManager.selectionText, 'ij"');
     });
   });
 
@@ -201,4 +209,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);
+    });
+  });
 });