From bc8497c6258869e76cc6813c1feaa0226ab6266c Mon Sep 17 00:00:00 2001 From: Edvin Hultberg Date: Thu, 27 Jul 2017 16:27:14 +0200 Subject: [PATCH 1/5] Attempt to fix specs --- spec/ex-commands-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/ex-commands-spec.coffee b/spec/ex-commands-spec.coffee index 4e3d839..d0c8744 100644 --- a/spec/ex-commands-spec.coffee +++ b/spec/ex-commands-spec.coffee @@ -764,7 +764,7 @@ describe "the commands", -> test = (escapeChar, escaped) -> openEx() - submitNormalModeInputText(":substitute/,/\\#{escapeChar}/g") + submitNormalModeInputText(":substitute/,/\#{escapeChar}/g") expect(editor.getText()).toEqual("abc#{escaped}def#{escaped}ghi") it "replaces with a tab", -> test('t', '\t') From 1c83400c12cc9432ecb91d28eeedaea1a8652efa Mon Sep 17 00:00:00 2001 From: Edvin Hultberg Date: Thu, 27 Jul 2017 16:38:00 +0200 Subject: [PATCH 2/5] revert 'fix' --- spec/ex-commands-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/ex-commands-spec.coffee b/spec/ex-commands-spec.coffee index d0c8744..4e3d839 100644 --- a/spec/ex-commands-spec.coffee +++ b/spec/ex-commands-spec.coffee @@ -764,7 +764,7 @@ describe "the commands", -> test = (escapeChar, escaped) -> openEx() - submitNormalModeInputText(":substitute/,/\#{escapeChar}/g") + submitNormalModeInputText(":substitute/,/\\#{escapeChar}/g") expect(editor.getText()).toEqual("abc#{escaped}def#{escaped}ghi") it "replaces with a tab", -> test('t', '\t') From 2d6f39c03762355e6f89ab1abff92e12f2ad01be Mon Sep 17 00:00:00 2001 From: Edvin Hultberg Date: Thu, 27 Jul 2017 16:51:11 +0200 Subject: [PATCH 3/5] fix tests --- spec/ex-commands-spec.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/ex-commands-spec.coffee b/spec/ex-commands-spec.coffee index 4e3d839..6ca46d8 100644 --- a/spec/ex-commands-spec.coffee +++ b/spec/ex-commands-spec.coffee @@ -764,12 +764,12 @@ describe "the commands", -> test = (escapeChar, escaped) -> openEx() - submitNormalModeInputText(":substitute/,/\\#{escapeChar}/g") + submitNormalModeInputText(":substitute/,/#{escapeChar}/g") expect(editor.getText()).toEqual("abc#{escaped}def#{escaped}ghi") - it "replaces with a tab", -> test('t', '\t') - it "replaces with a linefeed", -> test('n', '\n') - it "replaces with a carriage return", -> test('r', '\r') + it "replaces with a tab", -> test('\\t', '\t') + it "replaces with a linefeed", -> test('\\n', '\n') + it "replaces with a carriage return", -> test('\\r', '\r') describe "case sensitivity", -> describe "respects the smartcase setting", -> From 33c63b1cdccbb24e6dbaba0c045ed7e2fbb1ba7b Mon Sep 17 00:00:00 2001 From: Edvin Hultberg Date: Thu, 27 Jul 2017 17:17:18 +0200 Subject: [PATCH 4/5] Call backwardsScanInBufferRange for :%s --- lib/ex.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index e026b96..df78b6d 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -367,7 +367,10 @@ class Ex editor.transact -> for line in [range[0]..range[1]] - editor.scanInBufferRange( + # Following some simple testing and reading the atom docs + # calling backwardsScanInBufferRange is a better solution. + # https://atom.io/docs/api/v1.18.0/TextEditor#instance-backwardsScanInBufferRange + editor.backwardsScanInBufferRange( patternRE, [[line, 0], [line + 1, 0]], ({match, replace}) -> From bf9c2c476798a145fd15305b6662c116f14a4aeb Mon Sep 17 00:00:00 2001 From: Edvin Hultberg Date: Thu, 27 Jul 2017 17:33:37 +0200 Subject: [PATCH 5/5] hm.. does this work? --- lib/ex.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index df78b6d..e6af1fe 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -372,7 +372,7 @@ class Ex # https://atom.io/docs/api/v1.18.0/TextEditor#instance-backwardsScanInBufferRange editor.backwardsScanInBufferRange( patternRE, - [[line, 0], [line + 1, 0]], + [[line, 0], [line - 1, 0]], ({match, replace}) -> replace(replaceGroups(match[..], substition)) )