Skip to content

Commit

Permalink
🐛 Fix modified state subscriptions not changed when the editor is cha…
Browse files Browse the repository at this point in the history
…nged
  • Loading branch information
abe33 committed Nov 27, 2015
1 parent bc3f7e7 commit 8b38aac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/csv-editor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,15 @@ class CSVEditor

@getTableEditor(filePath, options, layout).then (tableEditor) =>
CSVEditor.tableEditorForPath[filePath] = tableEditor
@editorSubscriptions.dispose()
@editor = tableEditor
@subscribeToEditor()
@emitter.emit 'did-change', this
debounceChange()
.catch (err) =>
# The file content has changed for a format that cannot be parsed
# We drop the editor and replace it with the csv form
@editorSubscriptions.dispose()
@editor.destroy()
delete @editor
@emitter.emit 'did-change', this
Expand Down
24 changes: 24 additions & 0 deletions spec/csv-editor-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,30 @@ describe "CSVEditor", ->
['1', '2']
])

describe 'making new changes', ->
[modifiedSpy] = []

beforeEach ->
nextAnimationFrame()

modifiedSpy = jasmine.createSpy('did-change-modified')

csvEditor.onDidChangeModified(modifiedSpy)

describe 'on the previous table', ->
beforeEach ->
tableEditor.addRow ['Jack', 68, 'male']

it 'does not dispatch a did-change-modified event', ->
expect(modifiedSpy).not.toHaveBeenCalled()

describe 'on the new table', ->
beforeEach ->
csvEditor.editor.addRow ['Jack', 68, 'male']

it 'dispatches a did-change-modified event', ->
expect(modifiedSpy).toHaveBeenCalled()

describe 'when the table is in a modified state', ->
[conflictSpy] = []
beforeEach ->
Expand Down

0 comments on commit 8b38aac

Please sign in to comment.