]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Fix select all with no start and include content below viewport
authorDaniel Imms <daimms@microsoft.com>
Wed, 7 Jun 2017 06:13:50 +0000 (23:13 -0700)
committerDaniel Imms <daimms@microsoft.com>
Wed, 7 Jun 2017 06:13:50 +0000 (23:13 -0700)
src/SelectionManager.test.ts
src/SelectionManager.ts
src/SelectionModel.ts

index 5266030732de627af1e0f84b485710062c5fd579..e0ff6789712daa40fb42045b1c682ebe6ca2e93c 100644 (file)
@@ -44,7 +44,7 @@ describe('SelectionManager', () => {
       window = w;
       document = window.document;
       buffer = new CircularList<any>(100);
-      terminal = <any>{ cols: 80 };
+      terminal = <any>{ cols: 80, rows: 2 };
       selectionManager = new TestSelectionManager(terminal, buffer, rowContainer, null);
       done();
     });
@@ -153,4 +153,17 @@ describe('SelectionManager', () => {
       assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 0], 'The actual selection spans the entire column');
     });
   });
+
+  describe('selectAll', () => {
+    it('should select the entire buffer, beyond the viewport', () => {
+      buffer.push(stringToRow('1'));
+      buffer.push(stringToRow('2'));
+      buffer.push(stringToRow('3'));
+      buffer.push(stringToRow('4'));
+      buffer.push(stringToRow('5'));
+      selectionManager.selectAll();
+      terminal.ybase = buffer.length - terminal.rows;
+      assert.equal(selectionManager.selectionText, '1\n2\n3\n4\n5');
+    });
+  });
 });
index 04834d225b4a8f6711f5085f8486d3f78f8d9b18..3dcba40685eeb14116769f7a52d6328376c158a9 100644 (file)
@@ -160,7 +160,7 @@ export class SelectionManager extends EventEmitter {
     if (start[1] !== end[1]) {
       result.push(this._translateBufferLineToString(this._buffer.get(end[1]), true, 0, end[0]));
     }
-    console.log('selectionText result: "' + result + '"');
+
     return result.join('\n');
   }
 
index bcb7a9ced60aa6718a2765a004e7c57abb81e8d2..f1762e38475f65c4946ae5f5e82ceec0bd98029d 100644 (file)
@@ -52,12 +52,12 @@ export class SelectionModel {
    * word selection and triple click line selection.
    */
   public get finalSelectionEnd(): [number, number] {
-    if (!this.selectionStart) {
-      return null;
+    if (this.isSelectAllActive) {
+      return [this._terminal.cols - 1, this._terminal.ybase + this._terminal.rows - 1];
     }
 
-    if (this.isSelectAllActive) {
-      return [this._terminal.cols - 1, this._terminal.ydisp + this._terminal.rows - 1];
+    if (!this.selectionStart) {
+      return null;
     }
 
     // Use the selection start if the end doesn't exist or they're reversed