Skip to content

Commit

Permalink
Merge pull request #4607 from rlaverde/unwanted-scrolling-tabs
Browse files Browse the repository at this point in the history
PR: Fix unwanted scrolling when selecting tabs
  • Loading branch information
ccordoba12 authored Jun 16, 2017
2 parents 1b9421f + 725c015 commit e799cd5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions spyder/widgets/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def setup_editorstack(self, parent, layout):
# a crash when the editor is detached from the main window
# Fixes Issue 561
self.tabs.setDocumentMode(True)
self.tabs.currentChanged.connect(self.current_changed_tabs)
self.tabs.currentChanged.connect(self.current_changed)

if sys.platform == 'darwin':
tab_container = QWidget()
Expand Down Expand Up @@ -1210,7 +1210,11 @@ def set_stack_title(self, index, is_modified):
is_readonly = finfo.editor.isReadOnly()
tab_text = self.get_tab_text(index, is_modified, is_readonly)
tab_tip = self.get_tab_tip(fname, is_modified, is_readonly)
self.tabs.setTabText(index, tab_text)

# Only update tab text if have changed, otherwise an unwanted scrolling
# will happen when changing tabs. See Issue #1170.
if tab_text != self.tabs.tabText(index):
self.tabs.setTabText(index, tab_text)
self.tabs.setTabToolTip(index, tab_tip)


Expand Down Expand Up @@ -1621,17 +1625,14 @@ def get_todo_results(self):
if self.data:
return self.data[self.get_stack_index()].todo_results

def current_changed_tabs(self, index):
self.current_changed(index, set_focus=False)

def current_changed(self, index, set_focus=True):
def current_changed(self, index):
"""Stack index has changed"""
# count = self.get_stack_count()
# for btn in (self.filelist_btn, self.previous_btn, self.next_btn):
# btn.setEnabled(count > 1)

editor = self.get_current_editor()
if index != -1 and set_focus:
if index != -1:
editor.setFocus()
if DEBUG_EDITOR:
print("setfocusto:", editor, file=STDOUT)
Expand Down

0 comments on commit e799cd5

Please sign in to comment.