Added native JSON formatter.
Added icons for files in file locator.
UICodeEditorPlugin can request and draw gutter space.
This commit is contained in:
Martín Lucas Golini
2022-10-14 20:48:45 -03:00
parent 4da3d8e750
commit 0e4dc5d514
11 changed files with 235 additions and 107 deletions

View File

@@ -120,7 +120,13 @@ void FormatterPlugin::loadFormatterConfig( const std::string& path ) {
std::string data;
if ( !FileSystem::fileGet( path, data ) )
return;
json j = json::parse( data, nullptr, true, true );
json j;
try {
j = json::parse( data, nullptr, true, true );
} catch ( ... ) {
return;
}
if ( j.contains( "config" ) ) {
auto& config = j["config"];
@@ -385,6 +391,20 @@ void FormatterPlugin::registerNativeFormatters() {
return { false, "", "Couldn't parse CSS file." };
}
};
mNativeFormatters["json"] = []( const std::string& file ) -> NativeFormatterResult {
std::string data;
if ( !FileSystem::fileGet( file, data ) )
return { false, "", "Couldn't access JSON file." };
json j;
try {
j = json::parse( data, nullptr, true, true );
} catch ( ... ) {
return { false, "", "Error parsing JSON file." };
}
std::string res( j.dump( 2 ) );
return { !res.empty(), res, "" };
};
}
} // namespace ecode