From afd50964041e20a8a5cb68532bf1b0595d9795b7 Mon Sep 17 00:00:00 2001 From: abe33 Date: Mon, 9 May 2016 10:59:42 +0200 Subject: [PATCH] :bug: Fix issue with file name with CSV in it Fixes #45 --- lib/tablr.coffee | 8 +++++--- spec/csv-editor-spec.coffee | 7 +++++++ spec/fixtures/CSVExporter.coffee | 0 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 spec/fixtures/CSVExporter.coffee diff --git a/lib/tablr.coffee b/lib/tablr.coffee index e7f6349..cb7c08d 100644 --- a/lib/tablr.coffee +++ b/lib/tablr.coffee @@ -171,13 +171,13 @@ module.exports = type: 'array' default: ['csv', 'tsv', 'CSV', 'TSV'] description: 'The extensions for which the CSV opener will be used.' - + disablePreview: title: 'Disable preview' description: 'When checked, preview will not be presented.' type: 'boolean' default: false - + defaultColumnNamingMethod: type: 'string' default: 'alphabetic' @@ -200,7 +200,9 @@ module.exports = 'tablr:clear-csv-layout': => @csvConfig.clearOption('layout') @subscriptions.add atom.workspace.addOpener (uriToOpen) => - return unless ///\.#{atom.config.get('tablr.supportedCsvExtensions').join('|')}$///.test uriToOpen + console.log atom.config.get('tablr.supportedCsvExtensions').join('|') + console.log ///\.(#{atom.config.get('tablr.supportedCsvExtensions').join('|')})$///.test uriToOpen + return unless ///\.(#{atom.config.get('tablr.supportedCsvExtensions').join('|')})$///.test uriToOpen choice = @csvConfig.get(uriToOpen, 'choice') options = _.clone(@csvConfig.get(uriToOpen, 'options') ? {}) diff --git a/spec/csv-editor-spec.coffee b/spec/csv-editor-spec.coffee index 0530c3c..90ba32b 100644 --- a/spec/csv-editor-spec.coffee +++ b/spec/csv-editor-spec.coffee @@ -110,6 +110,13 @@ describe "CSVEditor", -> csvEditor?.destroy() temp.cleanup() + describe 'when opening a file whose name contains CSV', -> + it 'does not open a csv editor for the file', -> + waitsForPromise -> + atom.workspace.open('CSVExporter.coffee').then (t) -> csvEditor = t + runs -> + expect(csvEditor instanceof CSVEditor).toBeFalsy() + describe 'when an empty csv file is opened', -> it 'opens a csv editor for the file', -> openFixture('empty.csv') diff --git a/spec/fixtures/CSVExporter.coffee b/spec/fixtures/CSVExporter.coffee new file mode 100644 index 0000000..e69de29