From a0ceb786277bfc0ed43672b74c77c554fbb059ab Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 22 Nov 2013 14:38:13 -0800 Subject: [PATCH] Move snapshot code to package --- spec/editor-view-spec.coffee | 15 --------------- src/display-buffer.coffee | 6 ------ src/editor-view.coffee | 20 -------------------- src/editor.coffee | 7 ------- src/text-buffer.coffee | 6 ------ src/tokenized-buffer.coffee | 6 ------ 6 files changed, 60 deletions(-) diff --git a/spec/editor-view-spec.coffee b/spec/editor-view-spec.coffee index 34445a661..6afc45683 100644 --- a/spec/editor-view-spec.coffee +++ b/spec/editor-view-spec.coffee @@ -2706,21 +2706,6 @@ describe "EditorView", -> expect(buffer.lineForRow(15)).toBeUndefined() expect(editorView.getCursorBufferPosition()).toEqual [13, 0] - describe "editor:save-debug-snapshot", -> - it "saves the state of the rendered lines, the display buffer, and the buffer to a file of the user's choosing", -> - saveDialogCallback = null - spyOn(atom, 'showSaveDialog').andCallFake (callback) -> saveDialogCallback = callback - spyOn(fs, 'writeFileSync') - - editorView.trigger 'editor:save-debug-snapshot' - - statePath = path.join(temp.dir, 'state') - expect(atom.showSaveDialog).toHaveBeenCalled() - saveDialogCallback(statePath) - expect(fs.writeFileSync).toHaveBeenCalled() - expect(fs.writeFileSync.argsForCall[0][0]).toBe statePath - expect(typeof fs.writeFileSync.argsForCall[0][1]).toBe 'string' - describe "when the escape key is pressed on the editor view", -> it "clears multiple selections if there are any, and otherwise allows other bindings to be handled", -> atom.keymap.bindKeys 'name', '.editor', 'escape': 'test-event' diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index 9ffadc5ed..938551e85 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -584,12 +584,6 @@ class DisplayBuffer line = @lineForRow(row).text console.log row, line, line.length - getDebugSnapshot: -> - lines = ["Display Buffer:"] - for screenLine, row in @linesForRows(0, @getLastRow()) - lines.push "#{row}: #{screenLine.text}" - lines.join('\n') - ### Internal ### handleTokenizedBufferChange: (tokenizedBufferChange) => diff --git a/src/editor-view.coffee b/src/editor-view.coffee index c3e85cdf3..46f4e2285 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -205,7 +205,6 @@ class EditorView extends View 'editor:duplicate-line': @duplicateLine 'editor:join-line': @joinLine 'editor:toggle-indent-guide': => atom.config.toggle('editor.showIndentGuide') - 'editor:save-debug-snapshot': @saveDebugSnapshot 'editor:toggle-line-numbers': => atom.config.toggle('editor.showLineNumbers') 'editor:scroll-to-cursor': @scrollToCursorPosition @@ -1827,25 +1826,6 @@ class EditorView extends View commitTransaction: -> @activeEditSession.commitTransaction() abortTransaction: -> @activeEditSession.abortTransaction() - saveDebugSnapshot: -> - atom.showSaveDialog (path) => - fs.writeFileSync(path, @getDebugSnapshot()) if path - - getDebugSnapshot: -> - [ - "Debug Snapshot: #{@getPath()}" - @getRenderedLinesDebugSnapshot() - @activeEditSession.getDebugSnapshot() - @getBuffer().getDebugSnapshot() - ].join('\n\n') - - getRenderedLinesDebugSnapshot: -> - lines = ['Rendered Lines:'] - firstRenderedScreenRow = @firstRenderedScreenRow - @renderedLines.find('.line').each (n) -> - lines.push "#{firstRenderedScreenRow + n}: #{$(this).text()}" - lines.join('\n') - logScreenLines: (start, end) -> @activeEditSession.logScreenLines(start, end) diff --git a/src/editor.coffee b/src/editor.coffee index df85e3835..84f1bacdf 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -1437,10 +1437,3 @@ class Editor # Private: getSelectionMarkerAttributes: -> type: 'selection', editorId: @id, invalidate: 'never' - - # Private: - getDebugSnapshot: -> - [ - @displayBuffer.getDebugSnapshot() - @displayBuffer.tokenizedBuffer.getDebugSnapshot() - ].join('\n\n') diff --git a/src/text-buffer.coffee b/src/text-buffer.coffee index d669b5075..d3f9eac9f 100644 --- a/src/text-buffer.coffee +++ b/src/text-buffer.coffee @@ -670,9 +670,3 @@ class TextBuffer extends telepath.Model for row in [start..end] line = @lineForRow(row) console.log row, line, line.length - - getDebugSnapshot: -> - lines = ['TextBuffer:'] - for row in [0..@getLastRow()] - lines.push "#{row}: #{@lineForRow(row)}" - lines.join('\n') diff --git a/src/tokenized-buffer.coffee b/src/tokenized-buffer.coffee index 599b660ab..0b6ba31dd 100644 --- a/src/tokenized-buffer.coffee +++ b/src/tokenized-buffer.coffee @@ -322,9 +322,3 @@ class TokenizedBuffer for row in [start..end] line = @lineForScreenRow(row).text console.log row, line, line.length - - getDebugSnapshot: -> - lines = ["Tokenized Buffer:"] - for screenLine, row in @linesForScreenRows(0, @getLastRow()) - lines.push "#{row}: #{screenLine.text}" - lines.join('\n')