Skip to content

Commit

Permalink
Added 'scintillua.comment.[lang]' property for parent lexers with chi…
Browse files Browse the repository at this point in the history
…ldren.

Editors can use this for toggling comments.
  • Loading branch information
orbitalquark committed Dec 22, 2022
1 parent 994990f commit c6acb54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Scintillua.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ int lexer_field_newindex(lua_State *L) {
lua_getfield(L, LUA_REGISTRYINDEX, "scintillua"); // REGISTRY.scintillua
const auto lexer = reinterpret_cast<Scintillua *>(lua_touserdata(L, -1));
if (field == "property") {
static constexpr const char *validKeys[] = {"scintillua.comment", "scintillua.angle.braces"};
luaL_checkoption(L, 2, nullptr, validKeys);
if (strncmp(lua_tostring(L, 2), "scintillua.comment.", strlen("scintillua.comment.")) != 0) {
static constexpr const char *validKeys[] = {"scintillua.comment", "scintillua.angle.braces"};
luaL_checkoption(L, 2, nullptr, validKeys);
}
lexer->PropertySet(luaL_checkstring(L, 2), luaL_checkstring(L, 3));
} else if (field == "line_state") {
if (lua_getfield(L, LUA_REGISTRYINDEX, "buffer") != LUA_TLIGHTUSERDATA) // REGISTRY.buffer
Expand Down
2 changes: 2 additions & 0 deletions lexers/lexer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,8 @@ function M.load(name, alt_name)
lexer._parent_name, lexer._name = lexer._name, alt_name or name
end

M.property['scintillua.comment.' .. (alt_name or name)] = M.property['scintillua.comment']

return lexer
end

Expand Down

0 comments on commit c6acb54

Please sign in to comment.