Skip to content

Commit c9af66b

Browse files
committed
Clear the highlight, even if there is no new highlight
Closes #206
1 parent db41bca commit c9af66b

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

static/rustw.out.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ Object.defineProperty(exports, "__esModule", {
884884
value: true
885885
});
886886
exports.make_url = make_url;
887+
exports.unHighlight = unHighlight;
887888
exports.highlight_spans = highlight_spans;
888889
exports.request = request;
889890
exports.parseLink = parseLink;
@@ -899,14 +900,18 @@ function make_url(suffix) {
899900
return '/' + CONFIG.demo_mode_root_path + suffix;
900901
}
901902

902-
function highlight_spans(highlight, line_number_prefix, src_line_prefix, css_class, element) {
903-
// Remove any previous highlighting.
903+
function unHighlight(css_class, element) {
904904
if (element) {
905905
var highlighted = $(element).find('.' + css_class);
906906
highlighted.removeClass(css_class);
907907
var floating = $(element).find('.' + css_class + '.floating_highlight');
908908
floating.remove();
909909
}
910+
}
911+
912+
function highlight_spans(highlight, line_number_prefix, src_line_prefix, css_class, element) {
913+
// Remove any previous highlighting.
914+
unHighlight(css_class, element);
910915

911916
if (!highlight.line_start || !highlight.line_end) {
912917
return;
@@ -7545,6 +7550,8 @@ var SourceView = exports.SourceView = function (_React$Component) {
75457550

75467551
if (this.props.highlight) {
75477552
utils.highlight_spans(this.props.highlight, "src_line_number_", "src_line_", "selected", this.node);
7553+
} else {
7554+
utils.unHighlight("selected", this.node);
75487555
}
75497556

75507557
// Make source links active.

static/rustw.out.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/srcView.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ export class SourceView extends React.Component {
121121
componentDidUpdate() {
122122
if (this.props.highlight) {
123123
utils.highlight_spans(this.props.highlight, "src_line_number_", "src_line_", "selected", this.node);
124+
} else {
125+
utils.unHighlight("selected", this.node)
124126
}
125127

126128
// Make source links active.

static/utils.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ export function make_url(suffix) {
1010
return '/' + CONFIG.demo_mode_root_path + suffix;
1111
}
1212

13-
export function highlight_spans(highlight, line_number_prefix, src_line_prefix, css_class, element) {
14-
// Remove any previous highlighting.
13+
export function unHighlight(css_class, element) {
1514
if (element) {
1615
let highlighted = $(element).find('.' + css_class);
1716
highlighted.removeClass(css_class);
1817
let floating = $(element).find('.' + css_class + '.floating_highlight');
1918
floating.remove();
2019
}
2120

21+
}
22+
23+
export function highlight_spans(highlight, line_number_prefix, src_line_prefix, css_class, element) {
24+
// Remove any previous highlighting.
25+
unHighlight(css_class, element)
26+
2227
if (!highlight.line_start || !highlight.line_end) {
2328
return;
2429
}

0 commit comments

Comments
 (0)