diff --git a/Applications/TextMate/src/AppController Commands.mm b/Applications/TextMate/src/AppController Commands.mm index c033a5c2..01d1908d 100644 --- a/Applications/TextMate/src/AppController Commands.mm +++ b/Applications/TextMate/src/AppController Commands.mm @@ -43,7 +43,7 @@ OAK_DEBUG_VAR(AppController_Commands); { std::map map = oak::basic_environment(); map << item->bundle_variables(); - map = bundles::scope_variables(scope::context_t(), map); + map = bundles::scope_variables(map); map = variables_for_path(NULL_STR, scope::scope_t(), map); document::run(parse_command(item), ng::buffer_t(), ng::ranges_t(), document::document_ptr(), map); } diff --git a/Frameworks/OakFileBrowser/src/OakFileBrowser.mm b/Frameworks/OakFileBrowser/src/OakFileBrowser.mm index 1ade8555..5aaa6947 100644 --- a/Frameworks/OakFileBrowser/src/OakFileBrowser.mm +++ b/Frameworks/OakFileBrowser/src/OakFileBrowser.mm @@ -821,7 +821,7 @@ static NSMutableSet* SymmetricDifference (NSMutableSet* aSet, NSMutableSet* anot { std::map map = oak::basic_environment(); map << [self variables] << item->bundle_variables(); - map = bundles::scope_variables(scope::context_t(), map); + map = bundles::scope_variables(map); map = variables_for_path(to_s((NSString*)[self.selectedPaths firstObject]), scope::scope_t(), map); document::run(parse_command(item), ng::buffer_t(), ng::ranges_t(), [self.selectedPaths count] == 1 ? document::create(map["TM_SELECTED_FILE"]) : document::document_ptr(), map); } diff --git a/Frameworks/OakTextView/src/OakTextView.mm b/Frameworks/OakTextView/src/OakTextView.mm index f1daf2d7..48fa2866 100644 --- a/Frameworks/OakTextView/src/OakTextView.mm +++ b/Frameworks/OakTextView/src/OakTextView.mm @@ -1125,7 +1125,7 @@ doScroll: if([self.delegate respondsToSelector:@selector(variables)]) res << [self.delegate variables]; - res = bundles::scope_variables([self scopeContext], res); + res = bundles::scope_variables(res, [self scopeContext]); res = variables_for_path(document->path(), [self scopeContext].right, res); return res; } diff --git a/Frameworks/bundles/src/wrappers.cc b/Frameworks/bundles/src/wrappers.cc index d24fdf39..968ee48b 100644 --- a/Frameworks/bundles/src/wrappers.cc +++ b/Frameworks/bundles/src/wrappers.cc @@ -123,7 +123,7 @@ namespace bundles return res; } - std::map scope_variables (scope::context_t const& scope, std::map const& base) + std::map scope_variables (std::map const& base, scope::context_t const& scope) { std::map res = base; std::vector const& items = query(kFieldSettingName, "shellVariables", scope, kItemTypeSettings, oak::uuid_t(), false); diff --git a/Frameworks/bundles/src/wrappers.h b/Frameworks/bundles/src/wrappers.h index 637fb6e6..e2ca6c87 100644 --- a/Frameworks/bundles/src/wrappers.h +++ b/Frameworks/bundles/src/wrappers.h @@ -22,7 +22,7 @@ namespace bundles PUBLIC bool missing_requirement (item_ptr const& item, std::map& environment, required_command_t* failedRequirement); - PUBLIC std::map scope_variables (scope::context_t const& scope, std::map const& base = std::map()); + PUBLIC std::map scope_variables (std::map const& base, scope::context_t const& scope = scope::context_t()); PUBLIC plist::any_t value_for_setting (std::string const& setting, scope::context_t const& scope, item_ptr* match = NULL); PUBLIC std::vector grammars_for_path (std::string const& path); diff --git a/Frameworks/bundles/tests/t_query.cc b/Frameworks/bundles/tests/t_query.cc index abf9d715..ca17fbb0 100644 --- a/Frameworks/bundles/tests/t_query.cc +++ b/Frameworks/bundles/tests/t_query.cc @@ -131,24 +131,26 @@ public: void test_environment_format_strings () { - TS_ASSERT_EQUALS(bundles::scope_variables("")["TEST"], "foo"); - TS_ASSERT_EQUALS(bundles::scope_variables("source.c++")["TEST"], "foo:bar"); - TS_ASSERT_EQUALS(bundles::scope_variables("source.any")["TM_COMMENT_STYLE"], "Base Environment"); - TS_ASSERT_EQUALS(bundles::scope_variables("source.ruby")["TM_COMMENT_STYLE"], "Ruby Environment"); + std::map base; - TS_ASSERT_EQUALS(bundles::scope_variables("text.plain")["PATH"], "/usr/bin:/bin:/sbin"); - TS_ASSERT_EQUALS(bundles::scope_variables("text.tex")["PATH"], "/usr/bin:/bin:/sbin:/usr/texbin"); + TS_ASSERT_EQUALS(bundles::scope_variables(base, "")["TEST"], "foo"); + TS_ASSERT_EQUALS(bundles::scope_variables(base, "source.c++")["TEST"], "foo:bar"); + TS_ASSERT_EQUALS(bundles::scope_variables(base, "source.any")["TM_COMMENT_STYLE"], "Base Environment"); + TS_ASSERT_EQUALS(bundles::scope_variables(base, "source.ruby")["TM_COMMENT_STYLE"], "Ruby Environment"); + + TS_ASSERT_EQUALS(bundles::scope_variables(base, "text.plain")["PATH"], "/usr/bin:/bin:/sbin"); + TS_ASSERT_EQUALS(bundles::scope_variables(base, "text.tex")["PATH"], "/usr/bin:/bin:/sbin:/usr/texbin"); } void test_v1_variable_shadowing () { - std::map baseEnv = bundles::scope_variables(""); + auto baseEnv = bundles::scope_variables(std::map(), ""); TS_ASSERT_EQUALS(baseEnv["TM_COMMENT_START"], "/*"); TS_ASSERT_EQUALS(baseEnv["TM_COMMENT_STOP"], "*/"); TS_ASSERT_EQUALS(baseEnv["TM_COMMENT_START_2"], "//"); TS_ASSERT(baseEnv.find("TM_COMMENT_STOP_2") == baseEnv.end()); - std::map rubyEnv = bundles::scope_variables("source.ruby"); + std::map rubyEnv = bundles::scope_variables(std::map(), "source.ruby"); TS_ASSERT_EQUALS(rubyEnv["TM_COMMENT_START"], "# "); TS_ASSERT(rubyEnv.find("TM_COMMENT_STOP") == rubyEnv.end()); TS_ASSERT_EQUALS(rubyEnv["TM_COMMENT_START_2"], "==begin"); @@ -173,7 +175,7 @@ public: void test_require () { - TS_ASSERT_EQUALS(bundles::scope_variables("text")["DialogPath"], jail.path("Bundles/Dialog.tmbundle/Support/bin")); + TS_ASSERT_EQUALS(bundles::scope_variables(std::map(), "text")["DialogPath"], jail.path("Bundles/Dialog.tmbundle/Support/bin")); } void test_wrappers () diff --git a/Frameworks/editor/src/completion.cc b/Frameworks/editor/src/completion.cc index 305aaab1..074adb27 100644 --- a/Frameworks/editor/src/completion.cc +++ b/Frameworks/editor/src/completion.cc @@ -80,7 +80,7 @@ namespace ng env << editor_variables(scopeAttributes) << item->bundle_variables(); if(_document) env << _document->document_variables(); - env = bundles::scope_variables(this->scope(scopeAttributes), env); + env = bundles::scope_variables(env, this->scope(scopeAttributes)); env = variables_for_path(_document ? _document->path() : path::home(), this->scope(scopeAttributes).right, env); env["TM_CURRENT_WORD"] = prefix; diff --git a/Frameworks/file/src/filter.cc b/Frameworks/file/src/filter.cc index aefdec63..e451e635 100644 --- a/Frameworks/file/src/filter.cc +++ b/Frameworks/file/src/filter.cc @@ -151,7 +151,7 @@ namespace filter void run (bundles::item_ptr filter, std::string const& path, io::bytes_ptr content, callback_ptr context) { std::map variables = file::path_variables(path); - command::runner_ptr runner = command::runner(parse_command(filter), ng::buffer_t(), ng::ranges_t(), bundles::scope_variables(file::path_attributes(path), variables << filter->bundle_variables()), command::delegate_ptr(new event_delegate_t(content, context))); + command::runner_ptr runner = command::runner(parse_command(filter), ng::buffer_t(), ng::ranges_t(), bundles::scope_variables(variables << filter->bundle_variables(), file::path_attributes(path)), command::delegate_ptr(new event_delegate_t(content, context))); runner->launch(); }