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

[BUG] Current window width is not respected in VS Code Jupyter #3134

Closed
2 tasks done
ma-sadeghi opened this issue Sep 25, 2023 · 4 comments
Closed
2 tasks done

[BUG] Current window width is not respected in VS Code Jupyter #3134

ma-sadeghi opened this issue Sep 25, 2023 · 4 comments

Comments

@ma-sadeghi
Copy link

Describe the bug

rich doesn't respect the current window width when running in VS Code Jupyter. (See the horizontal slider)

image

Here's the code snippet to reproduce:

import logging
from rich.logging import RichHandler


FORMAT = "%(message)s"
logging.basicConfig(
    level="WARNING",
    format=FORMAT,
    datefmt="[%X]",
    handlers=[RichHandler(rich_tracebacks=True)]
)

log = logging.getLogger("test")
log.warning("This is a warning message!")

Platform

Click to expand
╭────────────────────── <class 'rich.console.Console'> ──────────────────────╮
 A high level console interface.                                            
                                                                            
 ╭────────────────────────────────────────────────────────────────────────╮ 
  <console width=115 ColorSystem.TRUECOLOR>                               
 ╰────────────────────────────────────────────────────────────────────────╯ 
                                                                            
     color_system = 'truecolor'                                             
         encoding = 'utf-8'                                                 
             file = <ipykernel.iostream.OutStream object at 0x7fc8e533d570> 
           height = 100                                                     
    is_alt_screen = False                                                   
 is_dumb_terminal = False                                                   
   is_interactive = False                                                   
       is_jupyter = True                                                    
      is_terminal = False                                                   
   legacy_windows = False                                                   
         no_color = False                                                   
          options = ConsoleOptions(                                         
                        size=ConsoleDimensions(width=115, height=100),      
                        legacy_windows=False,                               
                        min_width=1,                                        
                        max_width=115,                                      
                        is_terminal=False,                                  
                        encoding='utf-8',                                   
                        max_height=100,                                     
                        justify=None,                                       
                        overflow=None,                                      
                        no_wrap=False,                                      
                        highlight=None,                                     
                        markup=None,                                        
                        height=None                                         
                    )                                                       
            quiet = False                                                   
           record = False                                                   
         safe_box = True                                                    
             size = ConsoleDimensions(width=115, height=100)                
        soft_wrap = False                                                   
           stderr = False                                                   
            style = None                                                    
         tab_size = 8                                                       
            width = 115                                                     
╰────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
 Windows features available.                           
                                                       
 ╭───────────────────────────────────────────────────╮ 
  WindowsConsoleFeatures(vt=False, truecolor=False)  
 ╰───────────────────────────────────────────────────╯ 
                                                       
 truecolor = False                                     
        vt = False                                     
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ {                                  │
│     'TERM': 'xterm-color',         │
│     'COLORTERM': None,             │
│     'CLICOLOR': '1',               │
│     'NO_COLOR': None,              │
│     'TERM_PROGRAM': None,          │
│     'COLUMNS': None,               │
│     'LINES': None,                 │
│     'JUPYTER_COLUMNS': None,       │
│     'JUPYTER_LINES': None,         │
│     'JPY_PARENT_PID': None,        │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
╰────────────────────────────────────╯
platform="Linux"
@github-actions
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@ma-sadeghi
Copy link
Author

Here's extra information that might help debugging:

import rich
rich.get_console().size.width

Running above snippet in VS Code Jupyter always returns 115 on my machine, regardless of resizing the VS Code window.

@willmcgugan
Copy link
Collaborator

There is no way for Rich to know what the size of the window is in the browser.

@github-actions
Copy link

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants