Pārlūkot izejas kodu

Change order of commands returned by browser to prioritize commands used to open browsers on windows and mac (#419)

Change order of commands returned by browser to prioritize commands used to open browsers on windows and mac
Margaret Nolan 6 gadus atpakaļ
vecāks
revīzija
e027b505a0
1 mainītis faili ar 6 papildinājumiem un 5 dzēšanām
  1. 6
    5
      internal/driver/commands.go

+ 6
- 5
internal/driver/commands.go Parādīt failu

@@ -336,25 +336,26 @@ func listHelp(c string, redirect bool) string {
336 336
 }
337 337
 
338 338
 // browsers returns a list of commands to attempt for web visualization.
339
-// Commands which definitely will open a browser are prioritized over other
340
-// commands like xdg-open,  which may not open the javascript embedded SVG
341
-// files produced by the -web command in a browser.
342 339
 func browsers() []string {
343 340
 	var cmds []string
344 341
 	if userBrowser := os.Getenv("BROWSER"); userBrowser != "" {
345 342
 		cmds = append(cmds, userBrowser)
346 343
 	}
347
-	cmds = append(cmds, []string{"chrome", "google-chrome", "chromium", "firefox"}...)
348 344
 	switch runtime.GOOS {
349 345
 	case "darwin":
350 346
 		cmds = append(cmds, "/usr/bin/open")
351 347
 	case "windows":
352 348
 		cmds = append(cmds, "cmd /c start")
353 349
 	default:
350
+		// Commands opening browsers are prioritized over xdg-open, so browser()
351
+		// command can be used on linux to open the .svg file generated by the -web
352
+		// command (the .svg file includes embedded javascript so is best viewed in
353
+		// a browser).
354
+		cmds = append(cmds, []string{"chrome", "google-chrome", "chromium", "firefox", "sensible-browser"}...)
354 355
 		if os.Getenv("DISPLAY") != "" {
356
+			// xdg-open is only for use in a desktop environment.
355 357
 			cmds = append(cmds, "xdg-open")
356 358
 		}
357
-		cmds = append(cmds, "sensible-browser")
358 359
 	}
359 360
 	return cmds
360 361
 }