@@ -35,7 +35,7 @@ local function fast_parse(lang_tree)
3535 return parser :parse (old_trees [1 ], lang_tree ._source )
3636end
3737
38- --- @param apply fun ( module_name : string ):( string | nil ) Callback to apply the module name to
38+ --- @param apply fun ( module_name : string ):( string | nil ) Callback to apply the module name to. If the callback returns , this function returns.
3939--- @param content string The content to parse from
4040--- @param query_string ? string The tree-sitter query string with a ' @mod' capture
4141--- @return string | nil
@@ -48,8 +48,11 @@ local function treesitter_module_name(apply, content, query_string)
4848 --- @diagnostic disable-next-line
4949 for _ , match in module_query :iter_matches (root , content ) do
5050 for _ , node in ipairs (match ) do
51- local txt = vim .treesitter .get_node_text (node , content )
52- return apply (txt )
51+ local txt = vim .print (vim .treesitter .get_node_text (node , content ))
52+ local result = apply (txt )
53+ if result then
54+ return result
55+ end
5356 end
5457 end
5558end
5861local function get_buf_module_name (_ )
5962 local buf_content = table.concat (vim .api .nvim_buf_get_lines (0 , 0 , - 1 , false ), ' \n ' )
6063 return treesitter_module_name (function (mod )
61- return vim . print ( mod )
64+ return mod
6265 end , buf_content , ' [(module)(qualified_module)] @mod' )
6366end
6467
@@ -106,7 +109,6 @@ local function get_qualified_name_node(args)
106109 local choices = { insert (1 ) }
107110 if has_haskell_parser then
108111 treesitter_module_name (function (mod )
109- vim .print (mod )
110112 table.insert (choices , 1 , text (mod :sub (1 , 1 )))
111113 table.insert (choices , 1 , text (mod ))
112114 end , import_stmt )
0 commit comments