File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed
Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,11 @@ return function(client)
3232 })
3333
3434 --- Add a new watch expression
35- --- @param expr string
35+ --- @param expr ? string
3636 function dapui .elements .watches .add (expr )
37+ if not expr then
38+ expr = util .get_current_expr ()
39+ end
3740 watches .add (expr )
3841 end
3942
Original file line number Diff line number Diff line change @@ -226,7 +226,7 @@ local prev_expr = nil
226226---
227227--- If no fixed dimensions are given, the window will expand to fit the contents
228228--- of the buffer.
229- --- @param expr string Expression to evaluate. If nil , then in normal more the
229+ --- @param expr ? string Expression to evaluate. If nil , then in normal more the
230230--- current word is used, and in visual mode the currently highlighted text.
231231--- @param args dapui.EvalArgs
232232function dapui .eval (expr , args )
@@ -237,14 +237,7 @@ function dapui.eval(expr, args)
237237 end
238238 args = args or {}
239239 if not expr then
240- if vim .fn .mode () == " v" then
241- local start = async .fn .getpos (" v" )
242- local finish = async .fn .getpos (" ." )
243- local lines = util .get_selection (start , finish )
244- expr = table.concat (lines , " \n " )
245- else
246- expr = expr or async .fn .expand (" <cexpr>" )
247- end
240+ expr = util .get_current_expr ()
248241 end
249242 if open_float then
250243 if prev_expr == expr then
Original file line number Diff line number Diff line change @@ -26,6 +26,16 @@ function M.create_render_loop(render)
2626 end
2727end
2828
29+ function M .get_current_expr ()
30+ if async .fn .mode () == " v" then
31+ local start = async .fn .getpos (" v" )
32+ local finish = async .fn .getpos (" ." )
33+ local lines = M .get_selection (start , finish )
34+ return table.concat (lines , " \n " )
35+ end
36+ return async .fn .expand (" <cexpr>" )
37+ end
38+
2939function M .create_buffer (name , options )
3040 local buf = async .api .nvim_create_buf (true , true )
3141 options = vim .tbl_extend (" keep" , options or {}, {
You can’t perform that action at this time.
0 commit comments