Skip to content

Commit 934da70

Browse files
committed
Merge remote-tracking branch 'upstream/3.x' into find_in_files_bar
Merge!
2 parents 70d97db + 5c8a694 commit 934da70

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

Diff for: spyder/config/main.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@
233233
'occurrence_highlighting': True,
234234
'occurrence_highlighting/timeout': 1500,
235235
'always_remove_trailing_spaces': False,
236-
'fullpath_sorting': True,
237236
'show_tab_bar': True,
238237
'max_recent_files': 20,
239238
'save_all_before_run': True,
@@ -656,7 +655,7 @@
656655
# or if you want to *rename* options, then you need to do a MAJOR update in
657656
# version, e.g. from 3.0.0 to 4.0.0
658657
# 3. You don't need to touch this value if you're just adding a new option
659-
CONF_VERSION = '32.0.0'
658+
CONF_VERSION = '33.0.0'
660659

661660
# Main configuration instance
662661
try:

Diff for: spyder/plugins/editor.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,9 @@ def setup_page(self):
105105

106106
interface_group = QGroupBox(_("Interface"))
107107
newcb = self.create_checkbox
108-
fpsorting_box = newcb(_("Sort files according to full path"),
109-
'fullpath_sorting')
110108
showtabbar_box = newcb(_("Show tab bar"), 'show_tab_bar')
111109

112110
interface_layout = QVBoxLayout()
113-
interface_layout.addWidget(fpsorting_box)
114111
interface_layout.addWidget(showtabbar_box)
115112
interface_group.setLayout(interface_layout)
116113

@@ -1303,6 +1300,7 @@ def register_editorstack(self, editorstack):
13031300
editorstack.sig_prev_edit_pos.connect(self.go_to_last_edit_location)
13041301
editorstack.sig_prev_cursor.connect(self.go_to_previous_cursor_position)
13051302
editorstack.sig_next_cursor.connect(self.go_to_next_cursor_position)
1303+
editorstack.tabs.tabBar().tabMoved.connect(self.move_editorstack_data)
13061304

13071305
def unregister_editorstack(self, editorstack):
13081306
"""Removing editorstack only if it's not the last remaining"""
@@ -2641,3 +2639,21 @@ def set_create_new_file_if_empty(self, value):
26412639
"""Change the value of create_new_file_if_empty"""
26422640
for editorstack in self.editorstacks:
26432641
editorstack.create_new_file_if_empty = value
2642+
2643+
def move_editorstack_data(self, start, end):
2644+
"""Move editorstack.data to be synchronized when tabs are moved."""
2645+
if start < 0 or end < 0:
2646+
return
2647+
else:
2648+
steps = abs(end - start)
2649+
direction = (end-start) // steps # +1 for right, -1 for left
2650+
2651+
for editorstack in self.editorstacks :
2652+
data = editorstack.data
2653+
editorstack.blockSignals(True)
2654+
2655+
for i in range(start, end, direction):
2656+
data[i], data[i+direction] = data[i+direction], data[i]
2657+
2658+
editorstack.blockSignals(False)
2659+
editorstack.refresh()

Diff for: spyder/widgets/editor.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -560,14 +560,15 @@ def setup_editorstack(self, parent, layout):
560560
corner_widgets=corner_widgets)
561561
self.tabs.tabBar().setObjectName('plugin-tab')
562562
self.tabs.set_close_function(self.close_file)
563+
self.tabs.setMovable(True)
563564

564565
if hasattr(self.tabs, 'setDocumentMode') \
565566
and not sys.platform == 'darwin':
566567
# Don't set document mode to true on OSX because it generates
567568
# a crash when the editor is detached from the main window
568569
# Fixes Issue 561
569570
self.tabs.setDocumentMode(True)
570-
self.tabs.currentChanged.connect(self.current_changed)
571+
self.tabs.currentChanged.connect(self.current_changed_tabs)
571572

572573
if sys.platform == 'darwin':
573574
tab_container = QWidget()
@@ -926,7 +927,6 @@ def set_fullpath_sorting_enabled(self, state):
926927
self.fullpath_sorting_enabled = state
927928
if self.data:
928929
finfo = self.data[self.get_stack_index()]
929-
self.data.sort(key=self.__get_sorting_func())
930930
new_index = self.data.index(finfo)
931931
self.__repopulate_stack()
932932
self.set_stack_index(new_index)
@@ -1005,16 +1005,8 @@ def get_tab_tip(self, filename, is_modified=None, is_readonly=None):
10051005
else:
10061006
return text % (osp.basename(filename), osp.dirname(filename))
10071007

1008-
def __get_sorting_func(self):
1009-
if self.fullpath_sorting_enabled:
1010-
return lambda item: osp.join(osp.dirname(item.filename),
1011-
'_'+osp.basename(item.filename))
1012-
else:
1013-
return lambda item: osp.basename(item.filename)
1014-
10151008
def add_to_data(self, finfo, set_current):
10161009
self.data.append(finfo)
1017-
self.data.sort(key=self.__get_sorting_func())
10181010
index = self.data.index(finfo)
10191011
editor = finfo.editor
10201012
self.tabs.insertTab(index, editor, self.get_tab_text(index))
@@ -1051,7 +1043,6 @@ def rename_in_data(self, index, new_filename):
10511043
set_new_index = index == self.get_stack_index()
10521044
current_fname = self.get_current_filename()
10531045
finfo.filename = new_filename
1054-
self.data.sort(key=self.__get_sorting_func())
10551046
new_index = self.data.index(finfo)
10561047
self.__repopulate_stack()
10571048
if set_new_index:
@@ -1449,14 +1440,17 @@ def get_todo_results(self):
14491440
if self.data:
14501441
return self.data[self.get_stack_index()].todo_results
14511442

1452-
def current_changed(self, index):
1443+
def current_changed_tabs(self, index):
1444+
self.current_changed(index, set_focus=False)
1445+
1446+
def current_changed(self, index, set_focus=True):
14531447
"""Stack index has changed"""
14541448
# count = self.get_stack_count()
14551449
# for btn in (self.filelist_btn, self.previous_btn, self.next_btn):
14561450
# btn.setEnabled(count > 1)
14571451

14581452
editor = self.get_current_editor()
1459-
if index != -1:
1453+
if index != -1 and set_focus:
14601454
editor.setFocus()
14611455
if DEBUG_EDITOR:
14621456
print("setfocusto:", editor, file=STDOUT)

0 commit comments

Comments
 (0)