aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-04-22 21:20:59 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-04-22 21:34:40 +0200
commit287521cba09765d9d0901b79d8911a27de1af4e7 (patch)
tree8a505debc63763bca159ba0b6c60cae02d583d9e /vis.c
parent6d7794c0356902bc816923f4409d9d39a62db171 (diff)
downloadvis-287521cba09765d9d0901b79d8911a27de1af4e7.tar.gz
vis-287521cba09765d9d0901b79d8911a27de1af4e7.tar.xz
Cleanup line ending type detection and insertion
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c13
1 files changed, 11 insertions, 2 deletions
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);