Skip to content

Commit

Permalink
Altering InsertFootnoteCommand to allow inserting footnotes at EOF in…
Browse files Browse the repository at this point in the history
… the absence of a trailing newline.
  • Loading branch information
Joshua Geist committed Aug 28, 2012
1 parent 2aab22f commit 1fd84d0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion footnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ def run(self, edit):
edit = self.view.begin_edit()
startloc = self.view.sel()[-1].end()
markernum = get_next_footnote_marker(self.view)
self.view.insert(edit, self.view.find('\s', startloc).begin(), '[^%s]' % markernum)
if bool(self.view.size()):
targetloc = self.view.find('(\s|$)', startloc).begin()
else:
targetloc = 0
self.view.insert(edit, targetloc, '[^%s]' % markernum)
self.view.insert(edit, self.view.size(), '\n [^%s]: ' % markernum)
self.view.run_command('set_motion', {"inclusive": True, "motion": "move_to", "motion_args": {"extend": True, "to": "eof"}})
if self.view.settings().get('command_mode'):
Expand Down

0 comments on commit 1fd84d0

Please sign in to comment.