Skip to content

Commit

Permalink
Merge pull request #14 from SPBSTU-OrangeTeam/bugfix/saving
Browse files Browse the repository at this point in the history
Fix section was inserted in wrong place
  • Loading branch information
iOctav committed Jan 12, 2021
2 parents c676aed + 05d210b commit bc8ef57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion QuipEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def on_pre_save(self, view):
quip.edit_document(
thread_id=thread, content=line,
operation=2 if section else 0,
section_id=section
section_id=section, content_type='markdown'
)
for line, section in editor.deleted:
quip.edit_document(
Expand Down
9 changes: 6 additions & 3 deletions src/editor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ def _calculate(self, old, new):
edited.append((self._to_html(line), section))
continue
if i <= len(old_copy):
section = self._parse_id(old_copy[i-1])
new_lines.append((self._to_html(new[i]), section))
for index in range(i-1, 0, -1):
section = self._parse_id(new_copy[index])
if section:
break
new_lines.append((new[i], section))

edited_sections = [section for line,section in edited]
for i, copy in enumerate(old_copy):
Expand All @@ -36,7 +39,7 @@ def _calculate(self, old, new):
deleted.append((None, section))
old.remove(old[i-len(deleted)])

return new_lines, edited, deleted
return new_lines[::-1], edited, deleted

def _readlines(self, view):
try:
Expand Down

0 comments on commit bc8ef57

Please sign in to comment.