From 49e7337d07f3169fe9ed353f9166f38524a493a4 Mon Sep 17 00:00:00 2001 From: Matt Irvine Date: Thu, 4 Jan 2018 17:15:41 -0500 Subject: [PATCH 1/2] Initial commit for copy paste --- src/controllers/queryRunner.ts | 8 ++++++++ test/queryRunner.test.ts | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/controllers/queryRunner.ts b/src/controllers/queryRunner.ts index 98aed561a2..06cca0737d 100644 --- a/src/controllers/queryRunner.ts +++ b/src/controllers/queryRunner.ts @@ -335,7 +335,15 @@ export default class QueryRunner { p = p.then(tasks[i]); } p.then(() => { + let oldLang: string; + if (process.platform === 'darwin') { + oldLang = process.env['LANG']; + process.env['LANG'] = 'en_US.UTF-8'; + } ncp.copy(copyString, () => { + if (process.platform === 'darwin') { + process.env['LANG'] = oldLang; + } resolve(); }); }); diff --git a/test/queryRunner.test.ts b/test/queryRunner.test.ts index 110af50356..fbb7ae4433 100644 --- a/test/queryRunner.test.ts +++ b/test/queryRunner.test.ts @@ -504,7 +504,7 @@ suite('Query Runner tests', () => { '3' + TAB + '4' + CLRF + '5' + TAB + '6' + CLRF + '7' + TAB + '8' + CLRF + - '9' + TAB + '10'; + '9' + TAB + '10 ∞'; const finalStringWithHeader = 'Col1' + TAB + 'Col2' + CLRF + finalStringNoHeader; @@ -517,10 +517,11 @@ suite('Query Runner tests', () => { [{isNull: false, displayValue: '3'}, {isNull: false, displayValue: '4'}], [{isNull: false, displayValue: '5'}, {isNull: false, displayValue: '6'}], [{isNull: false, displayValue: '7'}, {isNull: false, displayValue: '8'}], - [{isNull: false, displayValue: '9'}, {isNull: false, displayValue: '10'}] + [{isNull: false, displayValue: '9'}, {isNull: false, displayValue: '10 ∞'}] ] } }; + process.env['LANG'] = 'C'; let testRange: ISlickRange[] = [{fromCell: 0, fromRow: 0, toCell: 1, toRow: 4}]; From 26621b54b405170ecbaf41e212d05b1b9ef8134b Mon Sep 17 00:00:00 2001 From: Matt Irvine Date: Fri, 9 Mar 2018 15:30:32 -0800 Subject: [PATCH 2/2] Fix tests on mac --- test/queryRunner.test.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/queryRunner.test.ts b/test/queryRunner.test.ts index fbb7ae4433..ff0de7d43b 100644 --- a/test/queryRunner.test.ts +++ b/test/queryRunner.test.ts @@ -571,7 +571,7 @@ suite('Query Runner tests', () => { ); queryRunner.uri = testuri; return queryRunner.copyResults(testRange, 0, 0).then(() => { - let pasteContents = ncp.paste(); + let pasteContents = pasteCopiedString(); assert.equal(pasteContents, finalStringNoHeader); }); }); @@ -594,7 +594,7 @@ suite('Query Runner tests', () => { // Call handleResult to ensure column header info is seeded queryRunner.handleQueryComplete(result); return queryRunner.copyResults(testRange, 0, 0).then(() => { - let pasteContents = ncp.paste(); + let pasteContents = pasteCopiedString(); assert.equal(pasteContents, finalStringWithHeader); }); }); @@ -619,7 +619,7 @@ suite('Query Runner tests', () => { // call copyResults with additional parameter indicating to include headers return queryRunner.copyResults(testRange, 0, 0, true).then(() => { - let pasteContents = ncp.paste(); + let pasteContents = pasteCopiedString(); assert.equal(pasteContents, finalStringWithHeader); }); }); @@ -644,7 +644,7 @@ suite('Query Runner tests', () => { // call copyResults with additional parameter indicating to not include headers return queryRunner.copyResults(testRange, 0, 0, false).then(() => { - let pasteContents = ncp.paste(); + let pasteContents = pasteCopiedString(); assert.equal(pasteContents, finalStringNoHeader); }); }); @@ -677,3 +677,16 @@ function setupStandardQueryNotificationHandlerMock(testQueryNotificationHandler: assert.equal(u, standardUri); }); } + +function pasteCopiedString(): string { + let oldLang: string; + if (process.platform === 'darwin') { + oldLang = process.env['LANG']; + process.env['LANG'] = 'en_US.UTF-8'; + } + let pastedString = ncp.paste(); + if (process.platform === 'darwin') { + process.env['LANG'] = oldLang; + } + return pastedString; +}