Skip to content

Commit

Permalink
Fix hover source display on multi-line search results
Browse files Browse the repository at this point in the history
  • Loading branch information
eira-fransham committed Jul 2, 2018
1 parent 301bbe0 commit c9b4ee4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
10 changes: 6 additions & 4 deletions static/rustw.out.js
Original file line number Diff line number Diff line change
Expand Up @@ -8043,7 +8043,7 @@ var FileResult = function (_React$Component2) {
app = _props2.app;

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

Expand Down Expand Up @@ -8078,18 +8078,20 @@ var FileResult = function (_React$Component2) {
};

var onMouseOver = function onMouseOver(e) {
self.setState({ peekContext: { pre: l.pre_context, post: l.post_context } });
self.setState({ peekContext: { line: i, pre: l.pre_context, post: l.post_context } });
e.preventDefault();
e.stopPropagation();
};
var onMouseOut = function onMouseOut(e) {
self.setState({ peekContext: null });
if (self.state.peekContext.line == i) {
self.setState({ peekContext: null });
}
e.preventDefault();
e.stopPropagation();
};

var context = null;
if (_this3.state.peekContext) {
if (_this3.state.peekContext && _this3.state.peekContext.line == i) {
context = _react2.default.createElement(SearchContext, { line: l.line, preContext: _this3.state.peekContext.pre, postContext: _this3.state.peekContext.post });
}

Expand Down
2 changes: 1 addition & 1 deletion static/rustw.out.js.map

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions static/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FileResult extends React.Component {
render() {
const { lines, file_name, kind, count, app } = this.props;
const self = this;
let divLines = lines.map((l) => {
let divLines = lines.map((l, i) => {
const lineId = `snippet_line_number_${kind}_${count}_${l.line_start}`;
const snippetId = `snippet_line_${kind}_${count}_${l.line_start}`;

Expand Down Expand Up @@ -81,18 +81,20 @@ class FileResult extends React.Component {
};

const onMouseOver = (e) => {
self.setState({ peekContext: { pre: l.pre_context, post: l.post_context }});
self.setState({ peekContext: { line: i, pre: l.pre_context, post: l.post_context } });
e.preventDefault();
e.stopPropagation();
}
const onMouseOut = (e) => {
self.setState({ peekContext: null });
if (self.state.peekContext.line == i) {
self.setState({ peekContext: null });
}
e.preventDefault();
e.stopPropagation();
}

let context = null;
if (this.state.peekContext) {
if (this.state.peekContext && this.state.peekContext.line == i) {
context = <SearchContext line={l.line} preContext={this.state.peekContext.pre} postContext={this.state.peekContext.post} />
}

Expand Down

0 comments on commit c9b4ee4

Please sign in to comment.