File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,8 @@ export async function exec(
68
68
}
69
69
try {
70
70
await fs . copy ( f , original ) ;
71
- const data = encode ( `${ content . join ( "\n" ) } \n` , fileencoding ) ;
71
+ const eol = getEol ( fileformat ) ;
72
+ const data = encode ( `${ content . join ( eol ) } ${ eol } ` , fileencoding ) ;
72
73
await Deno . writeFile ( original , bomb ? addBom ( data ) : data ) ;
73
74
await fn . setbufvar ( denops , bufnr , "&modified" , 0 ) ;
74
75
await execBare ( denops , [
@@ -86,6 +87,19 @@ export async function exec(
86
87
}
87
88
}
88
89
90
+ function getEol ( fileformat : string ) : string {
91
+ switch ( fileformat ) {
92
+ case "dos" :
93
+ return "\r\n" ;
94
+ case "unix" :
95
+ return "\n" ;
96
+ case "mac" :
97
+ return "\r" ;
98
+ default :
99
+ return "\n" ;
100
+ }
101
+ }
102
+
89
103
function encode ( str : string , encoding : string ) : Uint8Array {
90
104
const utf8Encoder = new TextEncoder ( ) ;
91
105
const utf8Bytes = utf8Encoder . encode ( str ) ;
You can’t perform that action at this time.
0 commit comments