Skip to content

Commit

Permalink
Ensure that there are always some lines in the buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
eush77 committed Jun 15, 2015
1 parent b6fced6 commit 8cd7095
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/document.js
Expand Up @@ -295,6 +295,8 @@ var methods = {

deleteLines: function (line, lines) {
this.lines.splice(line, lines)
if (!lines.length)
this.lines.push('\n')
while (lines)
this.emit('delete_line', '', 1, line + (lines --))
return this
Expand Down
2 changes: 1 addition & 1 deletion plugins/basics.js
Expand Up @@ -31,7 +31,7 @@ module.exports = function (doc, _, cursor) {
}
doc.lines = toLines(fs.readFileSync(file, 'utf-8'))
var last = doc.lines.pop()
if(last != '\n')
if(last != '\n' || !doc.lines.length)
doc.lines.push(last)
} catch (_) { }

Expand Down

0 comments on commit 8cd7095

Please sign in to comment.