Skip to content

Commit

Permalink
Change the link? method to extract iTerm version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Aug 10, 2024
1 parent f116087 commit 9ddcb91
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lib/tty/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ def link_to(name, url)
def link?
return false unless tty?

if iterm? && term_program_version
current_semantic_version = semantic_version(term_program_version)

return current_semantic_version >= semantic_version(3, 1, 0)
end
return iterm_version? if iterm? && term_program_version

if vte?
current_semantic_version = semantic_version(vte_version)
Expand All @@ -210,6 +206,21 @@ def iterm?
term_program =~ ITERM
end

# Detect whether the iTerm version supports terminal hyperlinks
#
# @example
# link.iterm_version?
# # => true
#
# @return [Boolean]
#
# @api private
def iterm_version?
current_semantic_version = semantic_version(term_program_version)

current_semantic_version >= semantic_version(3, 1, 0)
end

# Detect the terminal device
#
# @example
Expand Down

0 comments on commit 9ddcb91

Please sign in to comment.