Răsfoiți Sursa

refactor: remove redundant comments

ayn2op 2 ani în urmă
părinte
comite
50f32856c9
1 a modificat fișierele cu 8 adăugiri și 20 ștergeri
  1. 8 20
      cmd/run/message_input.go

+ 8 - 20
cmd/run/message_input.go

@@ -111,26 +111,17 @@ func (mi *MessageInput) launchEditorAction() {
 	if e == "default" {
 		e = os.Getenv("EDITOR")
 	}
-	
-	// Create a temporary (with discord_msg in the name) file 
-	// that we'll open in the editor. The reason is because 
-	// capturing Stdout to a variable actually causes editors 
-	// to not work for some reason, so we're going with the more
-	// reliable method.
-	f, err := os.CreateTemp("", config.Name + "-*.md")
+
+	f, err := os.CreateTemp("", config.Name+"-*.md")
 	if err != nil {
 		log.Println(err)
 		return
 	}
 	f.Close()
-	
-	// Defer this so the file is deleted when the
-	// function returns, regardless of failure or not
+
 	defer os.Remove(f.Name())
-	
+
 	cmd := exec.Command(e, f.Name())
-	// For some reason, editors won't open without setting
-	// these to their os counterparts.
 	cmd.Stdin = os.Stdin
 	cmd.Stdout = os.Stdout
 	cmd.Stderr = os.Stderr
@@ -142,13 +133,10 @@ func (mi *MessageInput) launchEditorAction() {
 			return
 		}
 	})
-	
-	// One may ask "Why don't we remove the file earlier?". Well,
-	// the file won't contain any message up until this point, and the file
-	// is created in /tmp anyway so it'll be cleared on a reboot.
-	msg, readErr := os.ReadFile(f.Name())
-	if readErr != nil {
-		log.Println(readErr)
+
+	msg, err := os.ReadFile(f.Name())
+	if err != nil {
+		log.Println(err)
 		return
 	}