class_docstr: Control that shows the meta information of the selected completion.
class_docstr_tok: ["Control","that","shows","the","meta","information","of","the","selected","completion","."]
docstr: Report the width of the longest meta text as the preferred width of this control.
  
  It could be that we use less width, but this way, we're sure that the
  layout doesn't change when we select another completion (E.g. that
  completions are suddenly shown in more or fewer columns.)
code: def preferred_width(self, max_available_width: int) -> int | None:
      """
      Report the width of the longest meta text as the preferred width of this control.
  
      It could be that we use less width, but this way, we're sure that the
      layout doesn't change when we select another completion (E.g. that
      completions are suddenly shown in more or fewer columns.)
      """
      app = get_app()
      if app.current_buffer.complete_state:
          state = app.current_buffer.complete_state
  
          if len(state.completions) >= 30:
              # When there are many completions, calling `get_cwidth` for
              # every `display_meta_text` is too expensive. In this case,
              # just return the max available width. There will be enough
              # columns anyway so that the whole screen is filled with
              # completions and `create_content` will then take up as much
              # space as needed.
              return max_available_width
  
          return 2 + max(
              get_cwidth(c.display_meta_text)
              for c in state.completions[:100]
          )
      else:
          return 0
  
imports: from __future__ import annotations
  import math
  from itertools import zip_longest
  from typing import TYPE_CHECKING, Callable, Iterable, Sequence, TypeVar, cast
  from weakref import WeakKeyDictionary
  from prompt_toolkit.application.current import get_app
  from prompt_toolkit.buffer import CompletionState
  from prompt_toolkit.completion import Completion
  from prompt_toolkit.data_structures import Point
  from prompt_toolkit.filters import Condition, FilterOrBool, has_completions, is_done, to_filter
  from prompt_toolkit.formatted_text import StyleAndTextTuples, fragment_list_width, to_formatted_text
  from prompt_toolkit.key_binding.key_processor import KeyPressEvent
  from prompt_toolkit.layout.utils import explode_text_fragments
  from prompt_toolkit.mouse_events import MouseEvent, MouseEventType
  from prompt_toolkit.utils import get_cwidth
  from .containers import ConditionalContainer, HSplit, ScrollOffsets, Window
  from .controls import GetLinePrefixCallable, UIContent, UIControl
  from .dimension import Dimension
  from .margins import ScrollbarMargin
label_desc: Use image node_id 1 for calling the _SelectedCompletionMetaControl obj's underlying member method code with example usage: obj.preferred_width(max_available_width) and returns: unknown, int, max_available_width