move to next search result while typing
parent
39a26c3c01
commit
79dafaf1a0
|
@ -102,6 +102,22 @@ make_file_buffer_panel :: proc(file_path: string, line: int = 0, col: int = 0) -
|
||||||
on_buffer_input = proc(panel: ^core.Panel, state: ^core.State) {
|
on_buffer_input = proc(panel: ^core.Panel, state: ^core.State) {
|
||||||
panel_state := &panel.type.(core.FileBufferPanel)
|
panel_state := &panel.type.(core.FileBufferPanel)
|
||||||
run_query(panel_state, &panel_state.buffer)
|
run_query(panel_state, &panel_state.buffer)
|
||||||
|
|
||||||
|
if len(panel_state.query_results) > 0 {
|
||||||
|
for result, i in panel_state.query_results {
|
||||||
|
cursor := panel_state.buffer.history.cursor
|
||||||
|
|
||||||
|
if result.line >= cursor.line || (result.line == cursor.line && result.col >= cursor.col) {
|
||||||
|
core.move_cursor_to_location(&panel_state.buffer, result.line, result.col)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if i == len(panel_state.query_results)-1 {
|
||||||
|
result := panel_state.query_results[0]
|
||||||
|
core.move_cursor_to_location(&panel_state.buffer, result.line, result.col)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
render = proc(panel: ^core.Panel, state: ^core.State) -> (ok: bool) {
|
render = proc(panel: ^core.Panel, state: ^core.State) -> (ok: bool) {
|
||||||
panel_state := &panel.type.(core.FileBufferPanel)
|
panel_state := &panel.type.(core.FileBufferPanel)
|
||||||
|
|
|
@ -290,7 +290,7 @@ rs_grep_as_results :: proc(results: ^RS_GrepResults, allocator := context.alloca
|
||||||
|
|
||||||
query_results := make([]core.GrepQueryResult, results.len)
|
query_results := make([]core.GrepQueryResult, results.len)
|
||||||
|
|
||||||
for i in 0..<results.len {
|
for i in 0..<len(query_results) {
|
||||||
r := results.results[i]
|
r := results.results[i]
|
||||||
|
|
||||||
query_results[i] = core.GrepQueryResult {
|
query_results[i] = core.GrepQueryResult {
|
||||||
|
|
Loading…
Reference in New Issue