|
| 1 | +local buffer = require('opencode.ui.renderer.buffer') |
| 2 | +local ctx = require('opencode.ui.renderer.ctx') |
| 3 | +local output_window = require('opencode.ui.output_window') |
| 4 | +local stub = require('luassert.stub') |
| 5 | + |
| 6 | +describe('renderer.buffer extmarks', function() |
| 7 | + local set_lines_stub |
| 8 | + local clear_extmarks_stub |
| 9 | + local set_extmarks_stub |
| 10 | + local highlight_changed_lines_stub |
| 11 | + |
| 12 | + before_each(function() |
| 13 | + ctx:reset() |
| 14 | + set_lines_stub = stub(output_window, 'set_lines') |
| 15 | + clear_extmarks_stub = stub(output_window, 'clear_extmarks') |
| 16 | + set_extmarks_stub = stub(output_window, 'set_extmarks') |
| 17 | + highlight_changed_lines_stub = stub(output_window, 'highlight_changed_lines') |
| 18 | + end) |
| 19 | + |
| 20 | + after_each(function() |
| 21 | + set_lines_stub:revert() |
| 22 | + clear_extmarks_stub:revert() |
| 23 | + set_extmarks_stub:revert() |
| 24 | + highlight_changed_lines_stub:revert() |
| 25 | + ctx:reset() |
| 26 | + end) |
| 27 | + |
| 28 | + it('reapplies extmarks on the first changed line when updating a part', function() |
| 29 | + ctx.render_state:set_part({ id = 'part_1', messageID = 'msg_1', type = 'text' }, 10, 11) |
| 30 | + |
| 31 | + buffer.upsert_part_now('part_1', 'msg_1', { |
| 32 | + lines = { 'alpha', 'gamma' }, |
| 33 | + extmarks = { |
| 34 | + [1] = { |
| 35 | + { line_hl_group = 'OpencodeReasoningText' }, |
| 36 | + }, |
| 37 | + }, |
| 38 | + actions = {}, |
| 39 | + }, { |
| 40 | + lines = { 'alpha', 'beta' }, |
| 41 | + extmarks = {}, |
| 42 | + actions = {}, |
| 43 | + }) |
| 44 | + |
| 45 | + assert.stub(clear_extmarks_stub).was_called_with(11, 12) |
| 46 | + assert.stub(set_extmarks_stub).was_called_with({ |
| 47 | + [0] = { |
| 48 | + { line_hl_group = 'OpencodeReasoningText' }, |
| 49 | + }, |
| 50 | + }, 11) |
| 51 | + end) |
| 52 | +end) |
0 commit comments