@@ -163,11 +163,6 @@ func LoadInput(args []string) []*buffer.Buffer {
163163 var err error
164164 buffers := make ([]* buffer.Buffer , 0 , len (args ))
165165
166- btype := buffer .BTDefault
167- if ! isatty .IsTerminal (os .Stdout .Fd ()) {
168- btype = buffer .BTStdout
169- }
170-
171166 files := make ([]string , 0 , len (args ))
172167
173168 flagStartPos := buffer.Loc {- 1 , - 1 }
@@ -222,27 +217,34 @@ func LoadInput(args []string) []*buffer.Buffer {
222217 // Option 1
223218 // We go through each file and load it
224219 for i := 0 ; i < len (files ); i ++ {
225- buf , err := buffer .NewBufferFromFileWithCommand (files [i ], btype , command )
220+ buf , err := buffer .NewBufferFromFileWithCommand (files [i ], buffer . BTDefault , command )
226221 if err != nil {
227222 screen .TermMessage (err )
228223 continue
229224 }
230225 // If the file didn't exist, input will be empty, and we'll open an empty buffer
231226 buffers = append (buffers , buf )
232227 }
233- } else if ! isatty .IsTerminal (os .Stdin .Fd ()) {
234- // Option 2
235- // The input is not a terminal, so something is being piped in
236- // and we should read from stdin
237- input , err = io .ReadAll (os .Stdin )
238- if err != nil {
239- screen .TermMessage ("Error reading from stdin: " , err )
240- input = []byte {}
241- }
242- buffers = append (buffers , buffer .NewBufferFromStringWithCommand (string (input ), filename , btype , command ))
243228 } else {
244- // Option 3, just open an empty buffer
245- buffers = append (buffers , buffer .NewBufferFromStringWithCommand (string (input ), filename , btype , command ))
229+ btype := buffer .BTDefault
230+ if ! isatty .IsTerminal (os .Stdout .Fd ()) {
231+ btype = buffer .BTStdout
232+ }
233+
234+ if ! isatty .IsTerminal (os .Stdin .Fd ()) {
235+ // Option 2
236+ // The input is not a terminal, so something is being piped in
237+ // and we should read from stdin
238+ input , err = io .ReadAll (os .Stdin )
239+ if err != nil {
240+ screen .TermMessage ("Error reading from stdin: " , err )
241+ input = []byte {}
242+ }
243+ buffers = append (buffers , buffer .NewBufferFromStringWithCommand (string (input ), filename , btype , command ))
244+ } else {
245+ // Option 3, just open an empty buffer
246+ buffers = append (buffers , buffer .NewBufferFromStringWithCommand (string (input ), filename , btype , command ))
247+ }
246248 }
247249
248250 return buffers
0 commit comments