Skip to content

Commit

Permalink
disable tab_apply_completion (tac) by default and rename as auto_comp…
Browse files Browse the repository at this point in the history
…lete_commit_on_tab (accot)
  • Loading branch information
marskar committed Oct 11, 2020
1 parent 8e74a0b commit 65210ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions radian/key_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,17 @@ def is_callable(text=""):
return False

@Condition
def tac():
return settings.tab_apply_completion
def accot():
return settings.auto_complete_commit_on_tab

insert_mode = vi_insert_mode | emacs_insert_mode
focused_insert = insert_mode & has_focus(DEFAULT_BUFFER)
shown_not_selected = has_completions & ~completion_is_selected
alt_enter = [KeyPress(Keys.Escape), KeyPress(Keys.Enter)]

# apply selected completion
@handle('c-j', filter=focused_insert & completion_is_selected & tac)
@handle("enter", filter=focused_insert & completion_is_selected & tac)
@handle('c-j', filter=focused_insert & completion_is_selected & accot)
@handle("enter", filter=focused_insert & completion_is_selected & accot)
def _(event):
b = event.current_buffer
text = b.text
Expand All @@ -367,8 +367,8 @@ def _(event):
event.cli.key_processor.feed_multiple(alt_enter)

# apply first completion option when completion menu is showing
@handle('c-j', filter=focused_insert & shown_not_selected & tac)
@handle("enter", filter=focused_insert & shown_not_selected & tac)
@handle('c-j', filter=focused_insert & shown_not_selected & accot)
@handle("enter", filter=focused_insert & shown_not_selected & accot)
def _(event):
b = event.current_buffer
text = b.text
Expand All @@ -381,8 +381,8 @@ def _(event):
event.cli.key_processor.feed_multiple(alt_enter)

# apply completion if there is only one option, otherwise start completion
@handle("tab", filter=focused_insert & ~has_completions & tac)
@handle("c-space", filter=focused_insert & ~has_completions & tac)
@handle("tab", filter=focused_insert & ~has_completions & accot)
@handle("c-space", filter=focused_insert & ~has_completions & accot)
def _(event):
b = event.current_buffer
complete_event = CompleteEvent(completion_requested=True)
Expand All @@ -397,8 +397,8 @@ def _(event):
b.start_completion(insert_common_part=True)

# apply first completion option if completion menu is showing
@handle("tab", filter=focused_insert & shown_not_selected & tac)
@handle("c-space", filter=focused_insert & shown_not_selected & tac)
@handle("tab", filter=focused_insert & shown_not_selected & accot)
@handle("c-space", filter=focused_insert & shown_not_selected & accot)
def _(event):
b = event.current_buffer
b.complete_next()
Expand All @@ -408,8 +408,8 @@ def _(event):
b.cursor_left()

# apply selected completion option
@handle("tab", filter=focused_insert & completion_is_selected & tac)
@handle("c-space", filter=focused_insert & completion_is_selected & tac)
@handle("tab", filter=focused_insert & completion_is_selected & accot)
@handle("c-space", filter=focused_insert & completion_is_selected & accot)
def _(event):
b = event.current_buffer
completion = b.complete_state.current_completion
Expand Down
2 changes: 1 addition & 1 deletion radian/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _load_prompt(self):

def load(self):
self._load_setting("auto_suggest", True, bool)
self._load_setting("tab_apply_completion", True, bool)
self._load_setting("auto_complete_commit_on_tab", False, bool)
self._load_setting("editing_mode", "emacs")
self._load_setting("color_scheme", "native")
self._load_setting("auto_match", True, bool)
Expand Down

0 comments on commit 65210ee

Please sign in to comment.