Skip to content

Commit 6075ec0

Browse files
committed
Merge pull request #1533 from mgreter/bugfix/parsing-file-too-early
Fix too early parser execution for initial file
2 parents e1085b6 + 0cb0640 commit 6075ec0

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/context.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace Sass {
113113
sort (c_importers.begin(), c_importers.end(), sort_importers);
114114
std::string entry_point = initializers.entry_point();
115115
if (!entry_point.empty()) {
116-
std::string result(add_file(entry_point));
116+
std::string result(add_file(entry_point, true));
117117
if (result.empty()) {
118118
throw "File to read not found or unreadable: " + entry_point;
119119
}
@@ -231,7 +231,7 @@ namespace Sass {
231231
}
232232

233233
// Add a new import file to the context
234-
std::string Context::add_file(const std::string& file)
234+
std::string Context::add_file(const std::string& file, bool delay)
235235
{
236236
using namespace File;
237237
std::string path(make_canonical_path(file));
@@ -240,8 +240,10 @@ namespace Sass {
240240
if (char* contents = read_file(resolved)) {
241241
add_source(path, resolved, contents);
242242
style_sheets[path] = 0;
243-
size_t i = queue.size() - 1;
244-
process_queue_entry(queue[i], i);
243+
if (delay == false) {
244+
size_t i = queue.size() - 1;
245+
process_queue_entry(queue[i], i);
246+
}
245247
return path;
246248
}
247249
return std::string("");

src/context.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace Sass {
110110
Block* parse_string();
111111
void add_source(std::string, std::string, char*);
112112

113-
std::string add_file(const std::string& imp_path);
113+
std::string add_file(const std::string& imp_path, bool delay = false);
114114
std::string add_file(const std::string& imp_path, const std::string& abs_path, ParserState pstate);
115115

116116
void process_queue_entry(Sass_Queued& entry, size_t idx);

0 commit comments

Comments
 (0)