mirror of
https://github.com/tstack/lnav.git
synced 2024-09-11 21:07:39 +03:00
[doc] disable guidelines when sane indents are not detected
This commit is contained in:
parent
2fc57c7f4c
commit
0a75daceec
@ -453,6 +453,27 @@ public:
|
||||
this->sw_hier_stage->hn_parent = nullptr;
|
||||
}
|
||||
|
||||
if (!this->sw_indents.empty()) {
|
||||
auto low_indent_iter = this->sw_indents.begin();
|
||||
|
||||
if (*low_indent_iter == 1) {
|
||||
// adding guides for small indents is noisy, drop for now
|
||||
this->sw_indents.clear();
|
||||
} else {
|
||||
auto lcm = *low_indent_iter;
|
||||
|
||||
for (auto indent_iter = this->sw_indents.begin();
|
||||
indent_iter != this->sw_indents.end();)
|
||||
{
|
||||
if ((*indent_iter % lcm) == 0) {
|
||||
++indent_iter;
|
||||
} else {
|
||||
indent_iter = this->sw_indents.erase(indent_iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mb.mb_root_node = std::move(this->sw_hier_stage);
|
||||
mb.mb_intervals = std::move(this->sw_intervals);
|
||||
mb.mb_type_intervals = std::move(this->sw_type_intervals);
|
||||
|
@ -64,6 +64,7 @@ detect_text_format(string_fragment sf,
|
||||
static const auto XML_EXT = ghc::filesystem::path(".xml");
|
||||
static const auto YAML_EXT = ghc::filesystem::path(".yaml");
|
||||
static const auto YML_EXT = ghc::filesystem::path(".yml");
|
||||
static const auto MAKEFILE_STEM = ghc::filesystem::path("Makefile");
|
||||
static const auto MD_EXT = ghc::filesystem::path(".md");
|
||||
static const auto MARKDOWN_EXT = ghc::filesystem::path(".markdown");
|
||||
|
||||
@ -124,6 +125,7 @@ detect_text_format(string_fragment sf,
|
||||
path = path->stem();
|
||||
}
|
||||
|
||||
auto stem = path->stem();
|
||||
auto ext = path->extension();
|
||||
if (ext == MD_EXT || ext == MARKDOWN_EXT) {
|
||||
return text_format_t::TF_MARKDOWN;
|
||||
@ -156,6 +158,10 @@ detect_text_format(string_fragment sf,
|
||||
if (ext == XML_EXT) {
|
||||
return text_format_t::TF_XML;
|
||||
}
|
||||
|
||||
if (stem == MAKEFILE_STEM) {
|
||||
return text_format_t::TF_MAKEFILE;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ enum class text_format_t {
|
||||
TF_JAVA,
|
||||
TF_JSON,
|
||||
TF_LOG,
|
||||
TF_MAKEFILE,
|
||||
TF_MAN,
|
||||
TF_MARKDOWN,
|
||||
TF_PYTHON,
|
||||
@ -95,6 +96,9 @@ struct formatter<text_format_t> : formatter<string_view> {
|
||||
case text_format_t::TF_JSON:
|
||||
name = "application/json";
|
||||
break;
|
||||
case text_format_t::TF_MAKEFILE:
|
||||
name = "text/x-makefile";
|
||||
break;
|
||||
case text_format_t::TF_MAN:
|
||||
name = "text/man";
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user