diff options
author | 2020-07-04 23:22:03 -0400 | |
---|---|---|
committer | 2020-07-04 23:22:03 -0400 | |
commit | 021866de868fd074526fc63270639ec2f3ce9aa5 (patch) | |
tree | e86d22cad0ba6d50f5db7c6768728ecf46a188e8 /test | |
parent | 9835ab92e265f4c83634f1bec49b4592e2deda8c (diff) |
Added `buffer:style_of_name()` as an analogue to `buffer:name_of_style()`.
Diffstat (limited to 'test')
-rw-r--r-- | test/test.lua | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/test/test.lua b/test/test.lua index 08881604..33e8fd67 100644 --- a/test/test.lua +++ b/test/test.lua @@ -2958,14 +2958,13 @@ end function test_view_split_refresh_styles() io.open_file(_HOME .. '/init.lua') - local GETNAMEDSTYLE = _SCINTILLA.properties.named_styles[1] - local style = buffer:private_lexer_call(GETNAMEDSTYLE, 'library') + local style = buffer:style_of_name('library') assert(style > 1, 'cannot retrieve number of library style') local color = view.style_fore[style] assert(color ~= view.style_fore[view.STYLE_DEFAULT], 'library style not set') view:split() for _, view in ipairs(_VIEWS) do - local view_style = buffer:private_lexer_call(GETNAMEDSTYLE, 'library') + local view_style = buffer:style_of_name('library') assert_equal(view_style, style) local view_color = view.style_fore[view_style] assert_equal(view_color, color) @@ -2998,7 +2997,21 @@ function test_set_theme() end function test_set_lexer_style() + buffer.new() + buffer:set_lexer('java') + buffer:add_text('foo()') + buffer:colorize(1, -1) + local style = buffer:style_of_name('function') + assert_equal(buffer.style_at[1], style) + local default_fore = view.style_fore[view.STYLE_DEFAULT] + assert(view.style_fore[style] ~= default_fore, 'function name style_fore same as default style_fore') + view.style_fore[style] = view.style_fore[view.STYLE_DEFAULT] + assert_equal(buffer.style_fore[style], default_fore) + buffer:close(true) -- Defined in Lua lexer, which is not currently loaded. + assert(buffer:style_of_name('library'), view.STYLE_DEFAULT) + -- Emulate a theme setting to trigger an LPeg lexer style refresh, but without + -- a token defined. view.property['style.library'] = view.property['style.library'] end |