Rewrite diagnostics popup with new api
This commit is contained in:
@@ -1,36 +1,33 @@
|
||||
#include "editor/editor.h"
|
||||
|
||||
// void hover_diagnostic(Editor *editor) {
|
||||
// static uint32_t last_line = UINT32_MAX;
|
||||
// if (last_line == editor->cursor.row && !editor->warnings_dirty)
|
||||
// return;
|
||||
// VWarn dummy;
|
||||
// dummy.line = editor->cursor.row;
|
||||
// editor->warnings_dirty = false;
|
||||
// last_line = editor->cursor.row;
|
||||
// auto first =
|
||||
// std::lower_bound(editor->warnings.begin(), editor->warnings.end(),
|
||||
// dummy);
|
||||
// auto last =
|
||||
// std::upper_bound(editor->warnings.begin(), editor->warnings.end(),
|
||||
// dummy);
|
||||
// std::vector<VWarn> warnings_at_line(first, last);
|
||||
// if (warnings_at_line.size() == 0) {
|
||||
// editor->diagnostics_active = false;
|
||||
// return;
|
||||
// }
|
||||
// editor->diagnostics.clear();
|
||||
// editor->diagnostics.warnings.swap(warnings_at_line);
|
||||
// editor->diagnostics.render_first();
|
||||
// editor->diagnostics_active = true;
|
||||
// }
|
||||
void hover_diagnostic(Editor *editor) {
|
||||
static uint32_t last_line = UINT32_MAX;
|
||||
if (last_line == editor->cursor.row && !editor->warnings_dirty)
|
||||
return;
|
||||
VWarn dummy;
|
||||
dummy.line = editor->cursor.row;
|
||||
editor->warnings_dirty = false;
|
||||
last_line = editor->cursor.row;
|
||||
auto first =
|
||||
std::lower_bound(editor->warnings.begin(), editor->warnings.end(), dummy);
|
||||
auto last =
|
||||
std::upper_bound(editor->warnings.begin(), editor->warnings.end(), dummy);
|
||||
std::vector<VWarn> warnings_at_line(first, last);
|
||||
if (warnings_at_line.size() == 0) {
|
||||
editor->diagnostic_popup->hidden = true;
|
||||
return;
|
||||
}
|
||||
editor->diagnostic_popup->clear();
|
||||
editor->diagnostic_popup->warnings.swap(warnings_at_line);
|
||||
editor->diagnostic_popup->hidden = false;
|
||||
}
|
||||
|
||||
void Editor::work() {
|
||||
if (!this->root)
|
||||
return;
|
||||
if (this->parser)
|
||||
this->parser->work();
|
||||
// hover_diagnostic(this);
|
||||
hover_diagnostic(this);
|
||||
// if (this->completion.active && this->completion.hover_dirty) {
|
||||
// this->completion.hover.render_first();
|
||||
// this->completion.hover_dirty = false;
|
||||
|
||||
Reference in New Issue
Block a user