bugfix: pin down schema1->y behavior

I want the topmost y coordinate for a given screen line.

I think.
This commit is contained in:
Kartik K. Agaram 2023-10-25 00:11:58 -07:00
parent 82865c4fea
commit 3fbd57887c
2 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,6 @@
y_of_schema1 = function(editor, loc)
local result = 0
loc = {line=loc.line, pos=Text.pos_at_start_of_screen_line(editor, loc)}
if loc.line == 1 and loc.pos == 1 then
return result
end
@ -15,4 +16,4 @@ y_of_schema1 = function(editor, loc)
result = result + editor.line_height
end
return result
end
end

8
0033-test_y_of_schema1 Normal file
View File

@ -0,0 +1,8 @@
test_y_of_schema1 = function()
local state = edit.initialize_test_state()
state.lines = load_array{'1', '2', '3'}
Text.redraw_all(state)
check_eq(y_of_schema1(state, {line=1, pos=1}), 0, 'start of first line')
check_eq(y_of_schema1(state, {line=1, pos=2}), 0, 'middle of first line')
check_eq(y_of_schema1(state, {line=2, pos=2}), state.line_height, 'middle of second line')
end