index+lenght for value_explorer

This commit is contained in:
Dmitry Vasilev
2023-06-19 06:33:57 +03:00
parent 315880176a
commit 7102e532f2
4 changed files with 16 additions and 6 deletions

View File

@@ -722,7 +722,8 @@ const select_return_value = state => {
node,
},
value_explorer: {
index: node.index + node.length,
index: node.index,
length: node.length,
result: result_node.result,
},
},
@@ -766,7 +767,8 @@ const select_arguments = (state, with_focus = true) => {
node,
},
value_explorer: {
index: node.index + node.length,
index: node.index,
length: node.length,
result,
},
},

View File

@@ -515,7 +515,8 @@ const eval_selection = (state, index, is_expand) => {
selection_state,
value_explorer: selection_state.ok
? {
index: selection_state.node.index + selection_state.node.length,
index: selection_state.node.index,
length: selection_state.node.length,
result,
}
: null
@@ -660,6 +661,7 @@ const get_value_explorer = (state, index) => {
// cursor in args, show args
return {
index: frame.children[0].index,
length: frame.children[0].length,
result: frame.children[0].result,
}
}
@@ -669,6 +671,7 @@ const get_value_explorer = (state, index) => {
const result = frame.children[1].result
return {
index: frame.children[1].index,
length: frame.children[1].length,
result: result.ok
? result
: find_error_origin_node(frame.children[1]).result
@@ -729,6 +732,7 @@ const get_value_explorer = (state, index) => {
} else if(stmt.type == 'let') {
return {
index: stmt.index,
length: stmt.length,
result:
{
ok: true,
@@ -755,7 +759,7 @@ const get_value_explorer = (state, index) => {
result = find_error_origin_node(stmt).result
}
return {index: stmt.index, result}
return {index: stmt.index, length: stmt.length, result}
}
const do_move_cursor = (state, index) => {

View File

@@ -199,7 +199,7 @@ export class Editor {
}
}
embed_value_explorer({index, result: {ok, value, error}}) {
embed_value_explorer({index, length, result: {ok, value, error}}) {
this.unembed_value_explorer()
const session = this.ace_editor.getSession()

View File

@@ -2262,8 +2262,10 @@ const y = x()`
// expand call
const s3 = COMMANDS.calltree.arrow_right(s2)
const s4 = COMMANDS.move_cursor(s3, code.indexOf('a'))
const selected = '(a, b)'
assert_equal(s4.value_explorer, {
index: code.indexOf('(a, b)'),
index: code.indexOf(selected),
length: selected.length,
result: {ok: true, value: {a: 1, b: 2}},
})
}),
@@ -2277,6 +2279,7 @@ const y = x()`
const s2 = COMMANDS.move_cursor(s1, code.indexOf('2'))
assert_equal(s2.value_explorer, {
index: code.indexOf('y*2'),
length: 3,
result: {ok: true, value: 4},
})
}),
@@ -2290,6 +2293,7 @@ const y = x()`
const s2 = COMMANDS.move_cursor(s1, code.indexOf('x'))
assert_equal(s2.value_explorer, {
index: code.indexOf('let x'),
length: 5,
result: {ok: true, value: {x: 1}},
})
}),