Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Don't show a file in the Editor immediately after it's selected in the switcher. #8836

Merged
merged 4 commits into from Mar 3, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 14 additions & 6 deletions spyder/widgets/fileswitcher.py
Expand Up @@ -193,17 +193,19 @@ class KeyPressFilter(QObject):

dalthviz marked this conversation as resolved.
Show resolved Hide resolved
sig_up_key_pressed = Signal()
sig_down_key_pressed = Signal()
sig_enter_key_pressed = Signal()

def eventFilter(self, src, e):
if e.type() == QEvent.KeyPress:
if e.key() == Qt.Key_Up:
self.sig_up_key_pressed.emit()
elif e.key() == Qt.Key_Down:
self.sig_down_key_pressed.emit()
elif (e.key() == Qt.Key_Enter) or (e.key() == Qt.Key_Return):
self.sig_enter_key_pressed.emit()

return super(KeyPressFilter, self).eventFilter(src, e)


class FilesFilterLine(QLineEdit):
"""QLineEdit used to filter files by name."""

Expand Down Expand Up @@ -290,6 +292,7 @@ def __init__(self, parent, plugin, tabs, data, icon):
self.rejected.connect(self.restore_initial_state)
self.filter.sig_up_key_pressed.connect(self.previous_row)
self.filter.sig_down_key_pressed.connect(self.next_row)
self.filter.sig_enter_key_pressed.connect(self.enter)
self.edit.returnPressed.connect(self.accept)
self.edit.textChanged.connect(self.setup)
self.list.itemSelectionChanged.connect(self.item_selection_changed)
Expand Down Expand Up @@ -609,13 +612,8 @@ def item_selection_changed(self):
try:
stack_index = self.paths.index(self.filtered_path[row])
self.plugin = self.widgets[stack_index][1]
plugin_index = self.plugins_instances.index(self.plugin)
# Count the real index in the tabWidget of the
# current plugin
dalthviz marked this conversation as resolved.
Show resolved Hide resolved
real_index = self.get_stack_index(stack_index,
plugin_index)
self.sig_goto_file.emit(real_index,
self.plugin.get_current_tab_manager())
self.goto_line(self.line_number)
try:
self.plugin.switch_to_plugin()
Expand All @@ -630,6 +628,16 @@ def item_selection_changed(self):
line_number = self.filtered_symbol_lines[row]
self.goto_line(line_number)

def enter(self):
row = self.current_row()
stack_index = self.paths.index(self.filtered_path[row])
self.plugin = self.widgets[stack_index][1]
plugin_index = self.plugins_instances.index(self.plugin)
real_index = self.get_stack_index(stack_index,
plugin_index)
self.sig_goto_file.emit(real_index,
self.plugin.get_current_tab_manager())

def setup_file_list(self, filter_text, current_path):
"""Setup list widget content for file list display."""
short_paths = shorten_paths(self.paths, self.save_status)
Expand Down