File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ local Footnote = require('orgmode.objects.footnote')
1111local Memoize = require (' orgmode.utils.memoize' )
1212local Buffers = require (' orgmode.state.buffers' )
1313
14+ local is_nightly = vim .fn .has (' nvim-0.13' ) == 1
15+
1416--- @class OrgFileMetadata
1517--- @field mtime number File modified time in nanoseconds
1618--- @field mtime_sec number File modified time in seconds
@@ -494,14 +496,17 @@ function OrgFile:get_node_text(node, range)
494496 if not node then
495497 return ' '
496498 end
499+ local opts = {}
497500 if range then
498- return ts .get_node_text (node , self :get_source (), {
499- metadata = {
500- range = range ,
501- },
502- })
501+ opts = { metadata = { range = range } }
502+ end
503+
504+ local _ , _ , _ , end_col = node :range ()
505+ local text = ts .get_node_text (node , self :get_source (), opts )
506+ if is_nightly and end_col == 0 and text :sub (- 1 ) == ' \n ' then
507+ return text :sub (1 , - 2 )
503508 end
504- return ts . get_node_text ( node , self : get_source ())
509+ return text
505510end
506511
507512--- @param node ? TSNode
You can’t perform that action at this time.
0 commit comments