Skip to content

Commit

Permalink
use start/end of selection for cursor position
Browse files Browse the repository at this point in the history
depending on the direction you're searching

fixes #2359
  • Loading branch information
gordonwoodhull committed Nov 11, 2016
1 parent 77d62bd commit 4552a5a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions htdocs/js/ui/find_replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ RCloud.UI.find_replace = (function() {
if(opts && opts.search_again) {

// get the cursor index:
var cursor_details = get_active_cell_cursor_details();
var cursor_details = get_active_cell_cursor_details(opts.next);

if(matches_.length && cursor_details) {

Expand Down Expand Up @@ -352,18 +352,18 @@ RCloud.UI.find_replace = (function() {

return focussed_cell;
}
function get_active_cell_cursor_details() {
function get_active_cell_cursor_details(use_end) {
var focussed_cell = get_focussed_cell();

if(!focussed_cell) {
return undefined;
}

var widget = focussed_cell.views[0].ace_widget();

var sel = widget.getSelectionRange();
return {
cell_index: focussed_cell.index,
cursor_index: widget.session.doc.positionToIndex(widget.getCursorPosition())
cursor_index: widget.session.doc.positionToIndex(use_end ? sel.end : sel.start)
};
}
function get_active_cell_selection() {
Expand Down

0 comments on commit 4552a5a

Please sign in to comment.