Skip to content

Commit

Permalink
Fixing key behaviours on editors (up, down and meta keys).
Browse files Browse the repository at this point in the history
  • Loading branch information
felipebiox committed Dec 14, 2020
1 parent deeb7e2 commit f1b209d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
37 changes: 20 additions & 17 deletions OmniDB/OmniDB_app/static/OmniDB_app/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -1048,25 +1048,28 @@ function autocomplete_keydown(p_editor, p_event) {

function autocomplete_update_editor_cursor(p_editor, p_event) {
// Handle UP or DOWN if autocomplete is not enbled, just move cursor position
if(p_event.keyCode === 40 || p_event.keyCode === 38){
var v_cursor_pos = p_editor.getCursorPosition();

//p_editor.moveCursorTo(p_editor.getCursorPosition().row+1,p_editor.getCursorPosition().column);
let v_target_row;
if(p_event.keyCode === 40) {
v_target_row = v_cursor_pos.row+1;
if (!p_event.shiftKey && !p_event.altKey && !p_event.ctrlKey && !p_event.metaKey) {
if(p_event.keyCode === 40 || p_event.keyCode === 38){
var v_cursor_pos = p_editor.getCursorPosition();

//p_editor.moveCursorTo(p_editor.getCursorPosition().row+1,p_editor.getCursorPosition().column);
let v_target_row;
if(p_event.keyCode === 40) {
v_target_row = v_cursor_pos.row+1;
}
else {
v_target_row = v_cursor_pos.row-1;
}
p_editor.moveCursorTo(v_target_row,v_cursor_pos.column);
p_editor.clearSelection();
p_editor.renderer.scrollCursorIntoView({row:v_target_row});
}
else {
v_target_row = v_cursor_pos.row-1;
// Handle TAB if autocomplete is not enbled
if(p_event.keyCode === 9){
var v_cursor_range = p_editor.getSelectionRange();
p_editor.indent();
p_editor.focus();
}
p_editor.moveCursorTo(v_target_row,v_cursor_pos.column);
p_editor.clearSelection();
p_editor.renderer.scrollCursorIntoView({row:v_target_row});
}
// Handle TAB if autocomplete is not enbled
if(p_event.keyCode === 9){
p_editor.insert('\t');
p_editor.focus();
}
// Enter
if (p_event.keyCode === 13) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ var v_createConsoleTabFunction = function() {
if (v_connTabControl.selectedTab.tag.enable_autocomplete !== false) {
autocomplete_start(v_editor1,1,event);
}
else {
autocomplete_update_editor_cursor(v_editor1, event);
}
});
$('#txt_input_' + v_tab.id).find('.ace_text-input').on('keydown',function(event){
if (v_connTabControl.selectedTab.tag.enable_autocomplete !== false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ var v_createQueryTabFunction = function(p_table, p_tab_db_id) {
if (v_connTabControl.selectedTab.tag.enable_autocomplete !== false) {
autocomplete_start(v_editor,0,event);
}
else {
autocomplete_update_editor_cursor(v_editor, event);
}
});
$('#txt_query_' + v_tab.id).find('.ace_text-input').on('keydown',function(event){
if (v_connTabControl.selectedTab.tag.enable_autocomplete !== false) {
Expand Down

0 comments on commit f1b209d

Please sign in to comment.