From 1dbfeabdffbc09d70ce67e0b2f695254364a357f Mon Sep 17 00:00:00 2001
From: Conrad Zelck <git@simpel.cc>
Date: Thu, 30 Dec 2021 19:05:09 +0000
Subject: [PATCH] feat: if unique lines checked remove empty lines

On top there will be all empty lines. If unique is checked I want to
delete this.

Known issue:
If there are lines with whitespaces they will stay and not removed.

Signed-off-by: Conrad Zelck <git@simpel.cc>
---
 script.js | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/script.js b/script.js
index d7703d1..930cd47 100644
--- a/script.js
+++ b/script.js
@@ -38,6 +38,14 @@ function sort_and_copy(ev){
   }
 
   lines = lines.sort(natural_compare);
+
+  // if there was an empty line it will be first array item now - remove
+  if (check_unique.checked) {
+    if (lines[0] == "") {
+      lines = lines.slice(1);
+    }
+  }
+
   textarea.value = lines.join("\n");
 
   window.getSelection().removeAllRanges();
-- 
GitLab