mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
HackStudio: Use GUI::TextDocument::span_at()
This commit is contained in:
parent
23c4f10027
commit
6365b44773
1 changed files with 13 additions and 15 deletions
|
@ -293,23 +293,21 @@ void Editor::mousedown_event(GUI::MouseEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& span : document().spans()) {
|
if (auto* span = document().span_at(text_position)) {
|
||||||
if (span.range.contains(text_position)) {
|
if (!highlighter->is_navigatable(span->data)) {
|
||||||
if (!highlighter->is_navigatable(span.data)) {
|
GUI::TextEditor::mousedown_event(event);
|
||||||
GUI::TextEditor::mousedown_event(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto adjusted_range = span.range;
|
|
||||||
adjusted_range.end().set_column(adjusted_range.end().column() + 1);
|
|
||||||
auto span_text = document().text_in_range(adjusted_range);
|
|
||||||
auto header_path = span_text.substring(1, span_text.length() - 2);
|
|
||||||
#ifdef EDITOR_DEBUG
|
|
||||||
dbgln("Ctrl+click: {} \"{}\"", adjusted_range, header_path);
|
|
||||||
#endif
|
|
||||||
navigate_to_include_if_available(header_path);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto adjusted_range = span->range;
|
||||||
|
adjusted_range.end().set_column(adjusted_range.end().column() + 1);
|
||||||
|
auto span_text = document().text_in_range(adjusted_range);
|
||||||
|
auto header_path = span_text.substring(1, span_text.length() - 2);
|
||||||
|
#ifdef EDITOR_DEBUG
|
||||||
|
dbgln("Ctrl+click: {} \"{}\"", adjusted_range, header_path);
|
||||||
|
#endif
|
||||||
|
navigate_to_include_if_available(header_path);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::TextEditor::mousedown_event(event);
|
GUI::TextEditor::mousedown_event(event);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue