diff --git a/README.md b/README.md
index 0b54a1b..d79fab0 100755
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ curl https://syedm.dev/crib | sh
```
Currently only for Linux.
-*Tested with arch linux and ubuntu and void*
+*Tested with arch linux, ubuntu and void*
## Building
diff --git a/include/editor/visual.h b/include/editor/visual.h
index 6dd8df8..021b193 100755
--- a/include/editor/visual.h
+++ b/include/editor/visual.h
@@ -35,8 +35,8 @@ struct VisualIterator {
std::stack> prev_stack;
VisualIterator(Knot *root, Coord pos, uint32_t width)
- : it(begin_l_iter(root, pos.row)), offset(pos.col),
- line_index(pos.row - 1), render_width(width) {}
+ : it(begin_l_iter(root, pos.row)), line_index(pos.row - 1),
+ offset(pos.col), render_width(width) {}
std::pair prev() {
if (!it)
diff --git a/include/lsp/lsp.h b/include/lsp/lsp.h
index ac9bd37..cb6ff4c 100755
--- a/include/lsp/lsp.h
+++ b/include/lsp/lsp.h
@@ -208,7 +208,7 @@ struct LSPInstance {
if (pfd.revents & POLLIN) {
json exit_msg = {{"jsonrpc", "2.0"}, {"method", "exit"}};
send_raw(exit_msg);
- int waited = 0;
+ uint32_t waited = 0;
while (waited < timeout) {
int status;
pid_t res = waitpid(pid, &status, WNOHANG);
diff --git a/include/utils/utils.h b/include/utils/utils.h
index bf811cf..58590b9 100755
--- a/include/utils/utils.h
+++ b/include/utils/utils.h
@@ -138,6 +138,7 @@ std::string percent_encode(const std::string &s);
std::string percent_decode(const std::string &s);
uint32_t count_clusters(const char *line, size_t len, size_t from, size_t to);
std::string trim(const std::string &s);
+std::string strip_newlines(const std::string &s);
std::string substitute_fence(const std::string &documentation,
const std::string &lang);
diff --git a/src/ui/bar.cc b/src/ui/bar.cc
index 684baa6..1078adc 100755
--- a/src/ui/bar.cc
+++ b/src/ui/bar.cc
@@ -5,7 +5,7 @@
#include "syntax/decl.h"
#include "windows/decl.h"
-void Bar::log(std::string message) { log_line = message; }
+void Bar::log(std::string message) { log_line = strip_newlines(message); }
void Bar::render(std::vector &buffer) {
USING(LSPInstance);
diff --git a/src/utils/system.cc b/src/utils/system.cc
index 97300ea..b8cb37e 100755
--- a/src/utils/system.cc
+++ b/src/utils/system.cc
@@ -59,6 +59,7 @@ char *load_file(const char *path, uint32_t *out_len, bool *out_eol) {
bool has_utf8_bom = (bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF);
uint32_t skip = has_utf8_bom ? 3 : 0;
uint32_t data_len = static_cast(len) - skip;
+ file.clear();
file.seekg(skip, std::ios::beg);
char *buf = (char *)malloc(data_len + 1);
if (!buf)
diff --git a/src/utils/text.cc b/src/utils/text.cc
index 093c89f..a3a2add 100755
--- a/src/utils/text.cc
+++ b/src/utils/text.cc
@@ -91,6 +91,15 @@ std::string trim(const std::string &s) {
return s.substr(start, end - start + 1);
}
+std::string strip_newlines(const std::string &s) {
+ std::string out;
+ out.reserve(s.size());
+ for (char c : s)
+ if (c != '\n' && c != '\r')
+ out.push_back(c);
+ return out;
+}
+
std::string clean_text(const std::string &input) {
std::string result = input;
static const std::unordered_map entities = {