Skip to content

Commit c9b4ee4

Browse files
committed
Fix hover source display on multi-line search results
1 parent 301bbe0 commit c9b4ee4

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

static/rustw.out.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8043,7 +8043,7 @@ var FileResult = function (_React$Component2) {
80438043
app = _props2.app;
80448044

80458045
var self = this;
8046-
var divLines = lines.map(function (l) {
8046+
var divLines = lines.map(function (l, i) {
80478047
var lineId = 'snippet_line_number_' + kind + '_' + count + '_' + l.line_start;
80488048
var snippetId = 'snippet_line_' + kind + '_' + count + '_' + l.line_start;
80498049

@@ -8078,18 +8078,20 @@ var FileResult = function (_React$Component2) {
80788078
};
80798079

80808080
var onMouseOver = function onMouseOver(e) {
8081-
self.setState({ peekContext: { pre: l.pre_context, post: l.post_context } });
8081+
self.setState({ peekContext: { line: i, pre: l.pre_context, post: l.post_context } });
80828082
e.preventDefault();
80838083
e.stopPropagation();
80848084
};
80858085
var onMouseOut = function onMouseOut(e) {
8086-
self.setState({ peekContext: null });
8086+
if (self.state.peekContext.line == i) {
8087+
self.setState({ peekContext: null });
8088+
}
80878089
e.preventDefault();
80888090
e.stopPropagation();
80898091
};
80908092

80918093
var context = null;
8092-
if (_this3.state.peekContext) {
8094+
if (_this3.state.peekContext && _this3.state.peekContext.line == i) {
80938095
context = _react2.default.createElement(SearchContext, { line: l.line, preContext: _this3.state.peekContext.pre, postContext: _this3.state.peekContext.post });
80948096
}
80958097

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/search.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class FileResult extends React.Component {
4646
render() {
4747
const { lines, file_name, kind, count, app } = this.props;
4848
const self = this;
49-
let divLines = lines.map((l) => {
49+
let divLines = lines.map((l, i) => {
5050
const lineId = `snippet_line_number_${kind}_${count}_${l.line_start}`;
5151
const snippetId = `snippet_line_${kind}_${count}_${l.line_start}`;
5252

@@ -81,18 +81,20 @@ class FileResult extends React.Component {
8181
};
8282

8383
const onMouseOver = (e) => {
84-
self.setState({ peekContext: { pre: l.pre_context, post: l.post_context }});
84+
self.setState({ peekContext: { line: i, pre: l.pre_context, post: l.post_context } });
8585
e.preventDefault();
8686
e.stopPropagation();
8787
}
8888
const onMouseOut = (e) => {
89-
self.setState({ peekContext: null });
89+
if (self.state.peekContext.line == i) {
90+
self.setState({ peekContext: null });
91+
}
9092
e.preventDefault();
9193
e.stopPropagation();
9294
}
9395

9496
let context = null;
95-
if (this.state.peekContext) {
97+
if (this.state.peekContext && this.state.peekContext.line == i) {
9698
context = <SearchContext line={l.line} preContext={this.state.peekContext.pre} postContext={this.state.peekContext.post} />
9799
}
98100

0 commit comments

Comments
 (0)