]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Merge branch 'master' into 724_fix_hasSelection
authorDaniel Imms <tyriar@tyriar.com>
Wed, 21 Jun 2017 15:34:33 +0000 (08:34 -0700)
committerGitHub <noreply@github.com>
Wed, 21 Jun 2017 15:34:33 +0000 (08:34 -0700)
src/SelectionManager.test.ts
src/SelectionManager.ts

index eb9322b6c0168bcf993d505f4e5825ca5de44999..dcc9cb5a9cf80074912da81029bb7f7fd0d97638 100644 (file)
@@ -209,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);
+    });
+  });
 });
index 3138048af6362923183fd7c4f734abd3c504bd47..b3316ae6cdad574ac79e867f3f64c491cf44de6a 100644 (file)
@@ -184,7 +184,12 @@ export class SelectionManager extends EventEmitter {
    * Gets whether there is an active text selection.
    */
   public get hasSelection(): boolean {
-    return !!this._model.finalSelectionStart && !!this._model.finalSelectionEnd;
+    const start = this._model.finalSelectionStart;
+    const end = this._model.finalSelectionEnd;
+    if (!start || !end) {
+      return false;
+    }
+    return start[0] !== end[0] || start[1] !== end[1];
   }
 
   /**