Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last line of semantic zone output not being returned in pane:get_text_from_semantic_zone(zone) #5346

Open
mgpinf opened this issue Apr 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mgpinf
Copy link

mgpinf commented Apr 27, 2024

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20240405-180910-cce0706b

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Last line of semantic zone output not being returned in pane:get_text_from_semantic_zone(zone). Rest of the content is present.
Enabled shell integration and tried in both zsh and fish.

Tried running the following command:
image

Obtained output (from logs):

01:01:57.041  INFO   logging > lua: total 0
drwxr-xr-x  2 unbxd  staff    64B Apr 28 00:40 another_dir
drwxr-xr-x  2 unbxd  staff    64B Apr 28 00:41 another_dir_2
drwxr-xr-x  2 unbxd  staff    64B Apr 28 00:38 dir1
-rw-r--r--  1 unbxd  staff     0B Apr 28 00:38 file1

To Reproduce

Enable shell integration in zsh/fish.
Add below config and try out

Configuration

{
  key = 'v',
  action = wezterm.action_callback(function(window, pane)
    local output_semantic_zones = pane:get_semantic_zones("Output")
    if #output_semantic_zones > 0 then
      local output_content
      for i = 1, #output_semantic_zones, 1 do
        output_content = pane:get_text_from_semantic_zone(output_semantic_zones[i])
        wezterm.log_info(output_content)
      end
    end
  end)
}

Expected Behavior

Expected output should include last line as well.

Logs

01:01:57.041  INFO   logging > lua: total 0
drwxr-xr-x  2 unbxd  staff    64B Apr 28 00:40 another_dir
drwxr-xr-x  2 unbxd  staff    64B Apr 28 00:41 another_dir_2
drwxr-xr-x  2 unbxd  staff    64B Apr 28 00:38 dir1
-rw-r--r--  1 unbxd  staff     0B Apr 28 00:38 file1

Anything else?

No response

@mgpinf mgpinf added the bug Something isn't working label Apr 27, 2024
@piechologist
Copy link

As a workaround, I've been using the following function ever since:

local function my_fixed_get_text_from_semantic_zone(pane, zone)
    -- Unfortunately, the function `get_text_from_semantic_zone(zone)` swallows the last line.
    -- So we need to get the region up to column 0 of the line that follows the zone.
    return pane:get_text_from_region(zone.start_x, zone.start_y, 0, zone.end_y + 1)
end

Then, you can call:

output_content = my_fixed_get_text_from_semantic_zone(pane, output_semantic_zones[i])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants