diff options
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r-- | Libraries/LibGUI/TextDocument.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibGUI/TextDocument.h | 10 | ||||
-rw-r--r-- | Libraries/LibGUI/TextEditor.cpp | 3 |
3 files changed, 8 insertions, 7 deletions
diff --git a/Libraries/LibGUI/TextDocument.cpp b/Libraries/LibGUI/TextDocument.cpp index 51d7323cd8..a303824a63 100644 --- a/Libraries/LibGUI/TextDocument.cpp +++ b/Libraries/LibGUI/TextDocument.cpp @@ -86,7 +86,7 @@ void TextDocument::set_text(const StringView& text) size_t TextDocumentLine::first_non_whitespace_column() const { for (size_t i = 0; i < length(); ++i) { - if (!isspace(m_text[(int)i])) + if (!isspace(m_text[i])) return i; } return length(); diff --git a/Libraries/LibGUI/TextDocument.h b/Libraries/LibGUI/TextDocument.h index 51234450b7..76ce03d23a 100644 --- a/Libraries/LibGUI/TextDocument.h +++ b/Libraries/LibGUI/TextDocument.h @@ -75,9 +75,9 @@ public: static NonnullRefPtr<TextDocument> create(Client* client = nullptr); ~TextDocument(); - size_t line_count() const { return (size_t)m_lines.size(); } - const TextDocumentLine& line(size_t line_index) const { return m_lines[(int)line_index]; } - TextDocumentLine& line(size_t line_index) { return m_lines[(int)line_index]; } + size_t line_count() const { return m_lines.size(); } + const TextDocumentLine& line(size_t line_index) const { return m_lines[line_index]; } + TextDocumentLine& line(size_t line_index) { return m_lines[line_index]; } void set_spans(const Vector<TextDocumentSpan>& spans) { m_spans = spans; } @@ -88,7 +88,7 @@ public: bool has_spans() const { return !m_spans.is_empty(); } const Vector<TextDocumentSpan>& spans() const { return m_spans; } - void set_span_at_index(size_t index, TextDocumentSpan span) { m_spans[(int)index] = move(span); } + void set_span_at_index(size_t index, TextDocumentSpan span) { m_spans[index] = move(span); } void append_line(NonnullOwnPtr<TextDocumentLine>); void remove_line(size_t line_index); @@ -156,7 +156,7 @@ public: StringView view() const { return { characters(), (size_t)length() }; } const char* characters() const { return m_text.data(); } - size_t length() const { return (size_t)m_text.size() - 1; } + size_t length() const { return m_text.size() - 1; } void set_text(TextDocument&, const StringView&); void append(TextDocument&, char); void prepend(TextDocument&, char); diff --git a/Libraries/LibGUI/TextEditor.cpp b/Libraries/LibGUI/TextEditor.cpp index fa501d3f95..6ee66b43f5 100644 --- a/Libraries/LibGUI/TextEditor.cpp +++ b/Libraries/LibGUI/TextEditor.cpp @@ -559,7 +559,8 @@ void TextEditor::move_selected_lines_down() get_selection_line_boundaries(first_line, last_line); auto& lines = document().lines(); - if (last_line >= (size_t)(lines.size() - 1)) + ASSERT(lines.size() != 0); + if (last_line >= lines.size() - 1) return; lines.insert((int)first_line, lines.take((int)last_line + 1)); |