Skip to content

Commit

Permalink
Fix renaming of notebook tab label during collaboration
Browse files Browse the repository at this point in the history
When Pippy is shared and joined, the notebook tab label is changed from
"New source file" to "New_source_file.py" on the joined instance.  A
side-effect of the _purify_file method.

* send the notebook tab label to the peers without purifying,

* make the _purify_file method public as purify_name,

* when the "go" button is pressed, purify the file name from the label,
  • Loading branch information
quozl committed Nov 14, 2019
1 parent 43b2009 commit 178abe1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _key_press_cb(self, widget, event):
def set_current_label(self, label):
child = self.get_nth_page(self.get_current_page())
widget = self.get_tab_label(child)
widget.set_text(self._purify_file(label))
widget.set_text(self.purify_name(label))

def set_current_path(self, path):
child = self.get_nth_page(self.get_current_page())
Expand All @@ -317,7 +317,7 @@ def get_text_view(self):
text_view = tab[0]
return text_view

def _purify_file(self, label):
def purify_name(self, label):
if not label.endswith('.py'):
label = label + '.py'

Expand All @@ -334,7 +334,7 @@ def get_all_data(self):
for i in range(0, self.get_n_pages()):
child = self.get_nth_page(i)

label = self._purify_file(self.get_tab_label(child).get_text())
label = self.get_tab_label(child).get_text()
names.append(label)

path = self.get_tab_label(child).get_path()
Expand All @@ -354,7 +354,7 @@ def get_all_data(self):
def get_current_file_name(self):
child = self.get_nth_page(self.get_current_page())
label = self.get_tab_label(child).get_text()
label = self._purify_file(label)
label = self.purify_name(label)

return label

Expand Down
1 change: 1 addition & 0 deletions pippy_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ def _write_all_buffers(self, tmp_dir):
data = self._source_tabs.get_all_data()
zipdata = list(zip(data[0], data[1]))
for name, content in zipdata:
name = self._source_tabs.purify_name(name)
with open(os.path.join(tmp_dir, name), 'w') as f:
# Write utf-8 coding prefix if there's not one already
if re.match(r'coding[:=]\s*([-\w.]+)',
Expand Down

0 comments on commit 178abe1

Please sign in to comment.