From 287521cba09765d9d0901b79d8911a27de1af4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 22 Apr 2015 21:20:59 +0200 Subject: Cleanup line ending type detection and insertion --- vis.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 8466034..e1ed0de 100644 --- a/vis.c +++ b/vis.c @@ -1092,8 +1092,17 @@ static void copy_indent_from_previous_line(View *view, Text *text) { } static void insert_newline(const Arg *arg) { - insert(&(const Arg){ .s = - text_newlines_crnl(vis->win->file->text) ? "\r\n" : "\n" }); + const char *nl; + switch (text_newline_type(vis->win->file->text)) { + case TEXT_NEWLINE_CRNL: + nl = "\r\n"; + break; + default: + nl = "\n"; + break; + } + + insert(&(const Arg){ .s = nl }); if (vis->autoindent) copy_indent_from_previous_line(vis->win->view, vis->win->file->text); -- cgit v1.2.3