From c174242aabb96f44e382bccdba71bd4b2b14e868 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Wed, 21 Mar 2012 14:45:28 -0700 Subject: [PATCH] Basic substitution works --- spec/atom/command-interpreter-spec.coffee | 4 ++-- src/atom/command-interpreter/substitution.coffee | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/spec/atom/command-interpreter-spec.coffee b/spec/atom/command-interpreter-spec.coffee index adec1a866..13f6ab209 100644 --- a/spec/atom/command-interpreter-spec.coffee +++ b/spec/atom/command-interpreter-spec.coffee @@ -11,8 +11,8 @@ describe "CommandInterpreter", -> interpreter = new CommandInterpreter(editor) describe "substitution", -> - fit "performs the substitution within the current dot", -> + it "performs the substitution within the current dot", -> editor.selection.setBufferRange([[6, 0], [6, 44]]) interpreter.eval('s/current/foo/') - expect(buffer.lineForRow(6)).toBe ' foo < pivot ? left.push(current) : right.push(current);' + expect(buffer.lineForRow(6)).toBe ' foo < pivot ? left.push(current) : right.push(current);' diff --git a/src/atom/command-interpreter/substitution.coffee b/src/atom/command-interpreter/substitution.coffee index 04633736f..acecfdb11 100644 --- a/src/atom/command-interpreter/substitution.coffee +++ b/src/atom/command-interpreter/substitution.coffee @@ -7,8 +7,6 @@ class Substitution { buffer } = editor selectedText = editor.getSelectedText() - # console.log editor.getSelection().getBufferRange() - selectionStartIndex = buffer.characterIndexForPosition(editor.getSelection().getBufferRange().start) match = @findRegex.exec(selectedText) @@ -18,5 +16,5 @@ class Substitution startPosition = buffer.positionForCharacterIndex(matchStartIndex) endPosition = buffer.positionForCharacterIndex(matchEndIndex) - buffer.change([startPosition, endPosition], @replace) + buffer.change([startPosition, endPosition], @replaceText)