diff --git a/app/models/repository.rb b/app/models/repository.rb
index 8a9213f659ce023d816c8b45069b37f1c45270ab..6262b5c4c92165bacedcf4f81b238eab8216dc42 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -442,7 +442,7 @@ class Repository
     filename = nil
     startline = 0
 
-    lines = result.lstrip.lines
+    lines = result.lines
     lines.each_with_index do |line, index|
       if line =~ /^.*:.*:\d+:/
         ref, filename, startline = line.split(':')
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index a083dcb127425cc2a9140c73c1c75bbf1f1231bf..d25351b0f0ebd475252c8df428bfaf6f862bf833 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -47,4 +47,28 @@ describe Repository do
       it { is_expected.to be_falsey }
     end
   end
+
+  describe "search_files" do
+    let(:results) { repository.search_files('feature', 'master') }
+    subject { results }
+
+    it { is_expected.to be_an Array }
+
+    describe 'result' do
+      subject { results.first }
+
+      it { is_expected.to be_an String }
+      it { expect(subject.lines[2]).to eq("master:CHANGELOG:188:  - Feature: Replace teams with group membership\n") }
+    end
+
+    describe 'parsing result' do
+      subject { repository.parse_search_result(results.first) }
+
+      it { is_expected.to be_an OpenStruct }
+      it { expect(subject.filename).to eq('CHANGELOG') }
+      it { expect(subject.ref).to eq('master') }
+      it { expect(subject.startline).to eq(186) }
+      it { expect(subject.data.lines[2]).to eq("  - Feature: Replace teams with group membership\n") }
+    end
+  end
 end