Skip to content

Commit

Permalink
🐛 Fix issue with file name with CSV in it
Browse files Browse the repository at this point in the history
Fixes #45
  • Loading branch information
abe33 committed May 9, 2016
1 parent 6fc2bba commit afd5096
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/tablr.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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') ? {})
Expand Down
7 changes: 7 additions & 0 deletions spec/csv-editor-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Empty file.

0 comments on commit afd5096

Please sign in to comment.