mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:08:11 +00:00
HackStudio: Fixed opening the project by always opening the main.cpp file
Now when opening the project a search will be made for a file with the extension cpp or js and opening it. If not found, the first file will be opened.
This commit is contained in:
parent
656ffe36f2
commit
8c4a2c34d3
1 changed files with 24 additions and 3 deletions
|
@ -302,11 +302,32 @@ RefPtr<ProjectFile> Project::get_file(const String& filename)
|
||||||
|
|
||||||
String Project::default_file() const
|
String Project::default_file() const
|
||||||
{
|
{
|
||||||
if (m_type == ProjectType::Cpp)
|
if (m_files.size() > 0) {
|
||||||
return "main.cpp";
|
if (m_type != ProjectType::Unknown) {
|
||||||
|
StringView extension;
|
||||||
|
switch (m_type) {
|
||||||
|
case ProjectType::Cpp:
|
||||||
|
extension = ".cpp";
|
||||||
|
break;
|
||||||
|
case ProjectType::JavaScript:
|
||||||
|
extension = ".js";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto project_file = m_files.find([&](auto project_file) {
|
||||||
|
return project_file->name().ends_with(extension);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!project_file.is_end()) {
|
||||||
|
auto& file = *project_file;
|
||||||
|
return file->name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_files.size() > 0)
|
|
||||||
return m_files.first().name();
|
return m_files.first().name();
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue