|
351 | 351 | local function filter_by_buffer(items, filter, opts, metadata) |
352 | 352 | local buffer_filtered = {} |
353 | 353 |
|
354 | | - if opts.debug then |
355 | | - logger.log("Buffer filtering for pattern: " .. filter.buffer_pattern) |
356 | | - end |
357 | | - |
358 | 354 | -- Step 1: Find all matching buffer headers |
359 | 355 | local matching_buffers, direct_match_count = find_matching_buffers(items, filter, opts, buffer_filtered) |
360 | 356 |
|
361 | | - if opts.debug then |
362 | | - logger.log("Matching buffers found: " .. vim.inspect(matching_buffers)) |
363 | | - logger.log("Buffer filtered items after first pass: " .. #buffer_filtered) |
364 | | - end |
365 | | - |
366 | 357 | -- Step 2: Add all symbols from matching buffers |
367 | 358 | add_buffer_symbols(items, matching_buffers, opts, buffer_filtered) |
368 | 359 |
|
@@ -497,30 +488,16 @@ local function filter_by_symbol(items, filter, opts, metadata) |
497 | 488 | -- If not preserving hierarchy, use a simple optimized filter |
498 | 489 | if not opts.preserve_hierarchy then |
499 | 490 | local filtered, count = filter_symbols_simple(items, kinds_lookup) |
500 | | - |
501 | 491 | -- Update metadata |
502 | 492 | metadata.filter_type = filter.filter_type |
503 | 493 | metadata.description = filter.description |
504 | 494 | metadata.direct_match_count = count |
505 | | - |
506 | 495 | return filtered, filter.remaining, metadata |
507 | 496 | end |
508 | 497 |
|
509 | 498 | -- For preserving hierarchy, use the hierarchical filter |
510 | 499 | local result_items, direct_match_count, parent_count = filter_symbols_hierarchy(items, kinds_lookup, opts) |
511 | 500 |
|
512 | | - -- Conditionally log only when debugging is enabled |
513 | | - if opts.debug then |
514 | | - logger.log( |
515 | | - string.format( |
516 | | - "Filter results: %d items (%d direct + %d parents)", |
517 | | - #result_items, |
518 | | - direct_match_count, |
519 | | - parent_count |
520 | | - ) |
521 | | - ) |
522 | | - end |
523 | | - |
524 | 501 | -- Update metadata |
525 | 502 | metadata.filter_type = filter.filter_type |
526 | 503 | metadata.description = filter.description |
@@ -618,7 +595,7 @@ function M.show_picker( |
618 | 595 | ui.apply_highlights(buf, filtered_items, opts) |
619 | 596 | end, |
620 | 597 | on_buffer_clear = function() |
621 | | - ui.clear_preview_highlight(state.original_win, state.preview_ns) |
| 598 | + ui.clear_preview_highlight(state.original_win, state.preview_ns, state) |
622 | 599 | if state.original_win and state.original_pos and api.nvim_win_is_valid(state.original_win) then |
623 | 600 | api.nvim_win_set_cursor(state.original_win, state.original_pos) |
624 | 601 | end |
@@ -665,7 +642,7 @@ function M.show_picker( |
665 | 642 | end, |
666 | 643 | on_close = function() |
667 | 644 | -- Always clean up preview highlights when picker closes |
668 | | - ui.clear_preview_highlight(state.original_win, state.preview_ns) |
| 645 | + ui.clear_preview_highlight(state.original_win, state.preview_ns, state) |
669 | 646 | end, |
670 | 647 | -- BUG: cursor position outside |
671 | 648 | -- Error /namu.nvim/lua/namu/core/symbol_utils.lua:889: Cursor position outside buffer |
@@ -758,71 +735,38 @@ function M.create_keymaps_handlers(opts, state, ui, selecta, ext, utils) |
758 | 735 | return true |
759 | 736 | end |
760 | 737 | end |
| 738 | + |
761 | 739 | handlers.quickfix = function(items_or_item, picker_state) |
762 | 740 | local items_to_send |
763 | | - |
764 | 741 | if type(items_or_item) == "table" and #items_or_item > 0 then |
765 | 742 | items_to_send = items_or_item |
766 | 743 | else |
767 | 744 | items_to_send = picker_state.filtered_items |
768 | 745 | end |
769 | | - |
770 | 746 | local success = selecta.add_to_quickfix(items_to_send, state) |
771 | 747 | if success and opts.actions.close_on_quickfix then |
772 | 748 | return true |
773 | 749 | end |
774 | 750 | return false |
775 | 751 | end |
776 | | - handlers.sidebar = function(items_or_item, picker_state) |
777 | | - -- Debug: Log the parameters |
778 | | - logger.log("=== SIDEBAR DEBUG ===") |
779 | | - logger.log("items_or_item type: " .. type(items_or_item)) |
780 | | - if type(items_or_item) == "table" and items_or_item.text then |
781 | | - logger.log("items_or_item is single item: " .. items_or_item.text) |
782 | | - elseif type(items_or_item) == "table" and #items_or_item > 0 then |
783 | | - logger.log("items_or_item is array with " .. #items_or_item .. " items") |
784 | | - end |
785 | | - |
786 | | - logger.log("picker_state type: " .. type(picker_state)) |
787 | | - if picker_state then |
788 | | - logger.log("picker_state.selected_count: " .. tostring(picker_state.selected_count)) |
789 | | - logger.log("picker_state.filtered_items count: " .. (#picker_state.filtered_items or 0)) |
790 | | - end |
791 | 752 |
|
| 753 | + handlers.sidebar = function(items_or_item, picker_state) |
792 | 754 | local items_to_show |
793 | | - |
794 | | - -- Check if we received selected items as first parameter |
795 | 755 | if type(items_or_item) == "table" and #items_or_item > 0 and items_or_item[1] and items_or_item[1].text then |
796 | | - -- We received an array of selected items |
797 | 756 | items_to_show = items_or_item |
798 | | - logger.log("Using selected items passed as parameter") |
799 | 757 | else |
800 | | - -- We received a single item, use all filtered items from picker state |
801 | 758 | items_to_show = picker_state.filtered_items |
802 | | - logger.log("Using all filtered items from picker state") |
803 | 759 | end |
804 | | - |
805 | | - logger.log("items_to_show type: " .. type(items_to_show)) |
806 | | - if items_to_show then |
807 | | - logger.log("items_to_show count: " .. #items_to_show) |
808 | | - end |
809 | | - logger.log("=== END SIDEBAR DEBUG ===") |
810 | | - |
811 | 760 | local original_picker_opts = picker_state.original_opts or {} |
812 | | - if original_picker_opts then |
813 | | - logger.log("Original picker options found: " .. vim.inspect(picker_state)) |
814 | | - end |
815 | 761 | -- Create sidebar options by copying ALL original options |
816 | 762 | local sidebar_opts = vim.tbl_deep_extend("force", original_picker_opts, { |
817 | 763 | -- Only override sidebar-specific settings |
818 | 764 | sidebar_mode = true, |
819 | 765 | position = picker_config.sidebar and picker_config.sidebar.position or "right", |
820 | 766 | width = picker_config.sidebar and picker_config.sidebar.width or 40, |
821 | 767 | }) |
822 | | - |
823 | 768 | selecta.create_sidebar(items_to_show, sidebar_opts, state) |
824 | | - |
825 | | - return true -- Close original picker |
| 769 | + return true |
826 | 770 | end |
827 | 771 |
|
828 | 772 | handlers.bookmark = function(items_or_item, picker_state) |
|
0 commit comments