Skip to content

Commit

Permalink
Don't filter header lines via the & command.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Sep 11, 2023
1 parent 434f70c commit f49b3db
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ public int edit_ifile(IFILE ifile)
}
if (want_filesize)
scan_eof();
set_header_end_pos();
}
return (0);
}
Expand Down
2 changes: 2 additions & 0 deletions optfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,8 @@ public void opt_header(int type, char *s)
else
header_cols = n;
}
if (type == TOGGLE)
set_header_end_pos();
break;
case QUERY:
{
Expand Down
26 changes: 24 additions & 2 deletions search.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern int can_goto_line;
static int hide_hilite;
static POSITION prep_startpos;
static POSITION prep_endpos;
extern POSITION xxpos;
static POSITION header_end_pos = NULL_POSITION;

/*
* Structures for maintaining a set of ranges for hilites and filtered-out
Expand Down Expand Up @@ -495,6 +495,22 @@ static int hilited_range_attr(POSITION pos, POSITION epos)
return n->r.hl_attr;
}

/*
* Determine and save the position of the first char after any header lines.
*/
public void set_header_end_pos(void)
{
header_end_pos = (header_lines == 0) ? NULL_POSITION : find_pos(header_lines+1);
}

/*
* Is a position within the header lines?
*/
static int pos_in_header(POSITION pos)
{
return (header_end_pos != NULL_POSITION && pos < header_end_pos);
}

/*
* Is a line "filtered" -- that is, should it be hidden?
*/
Expand All @@ -503,7 +519,9 @@ public int is_filtered(POSITION pos)
struct hilite_node *n;

if (ch_getflags() & CH_HELPFILE)
return (0);
return (FALSE);
if (pos_in_header(pos))
return (FALSE);

n = hlist_find(&filter_anchor, pos);
return (n != NULL && pos >= n->r.hl_startpos);
Expand All @@ -519,6 +537,8 @@ public POSITION next_unfiltered(POSITION pos)

if (ch_getflags() & CH_HELPFILE)
return (pos);
if (pos_in_header(pos))
return (pos);

n = hlist_find(&filter_anchor, pos);
while (n != NULL && pos >= n->r.hl_startpos)
Expand All @@ -539,6 +559,8 @@ public POSITION prev_unfiltered(POSITION pos)

if (ch_getflags() & CH_HELPFILE)
return (pos);
if (pos_in_header(pos))
return (pos);

n = hlist_find(&filter_anchor, pos);
while (n != NULL && pos >= n->r.hl_startpos)
Expand Down

0 comments on commit f49b3db

Please sign in to comment.