Skip to content

Commit 7f1c3d9

Browse files
ahornacetarzanek
authored andcommitted
Fix search matching first line has a line number 0
fixes #2033
1 parent 794f32a commit 7f1c3d9

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/org/opensolaris/opengrok/search/context/PlainLineTokenizer.lex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ import org.opensolaris.opengrok.analysis.Scopes.Scope;
5454
* first line part of the matching region.
5555
*/
5656
private final StringBuilder markedContents = new StringBuilder();
57-
int markedPos=0;
58-
int curLinePos=0;
59-
int matchStart=-1;
60-
int markedLine=0;
61-
int rest=0;
57+
int markedPos = 0;
58+
int curLinePos = 0;
59+
int matchStart = -1;
60+
int markedLine = 1; // lines are indexed from 1
61+
int rest = 0;
6262
boolean wait = false;
6363
boolean dumpRest = false;
6464
Writer out;
@@ -115,10 +115,10 @@ import org.opensolaris.opengrok.analysis.Scopes.Scope;
115115
wait = false;
116116
dumpRest = false;
117117
rest = 0;
118-
markedPos=0;
119-
curLinePos=0;
120-
matchStart=-1;
121-
markedLine=0;
118+
markedPos = 0;
119+
curLinePos = 0;
120+
matchStart = -1;
121+
markedLine = 1;
122122
yyline = 1;
123123
this.out = out;
124124
this.url = url;

test/org/opensolaris/opengrok/search/context/ContextTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public void bug16848() throws Exception {
409409
QueryBuilder qb = new QueryBuilder().setFreetext("mixed");
410410
Context c = new Context(qb.build(), qb.getQueries());
411411
assertTrue(c.getContext(in, out, "", "", "", null, false, qb.isDefSearch(), null));
412-
assertEquals("<a class=\"s\" href=\"#0\"><span class=\"l\">0</span> "
412+
assertEquals("<a class=\"s\" href=\"#1\"><span class=\"l\">1</span> "
413413
+ "<b>Mixed</b> case: abc AbC dEf</a><br/>",
414414
out.toString());
415415
}

0 commit comments

Comments
 (0)