class RubyLsp::Requests::Support::RuboCopDiagnostic

def line_disable_comment

: -> Array[Interface::TextEdit]
def line_disable_comment
  new_text = if @offense.source_line.include?(" # rubocop:disable ")
    ",#{@offense.cop_name}"
  else
    " # rubocop:disable #{@offense.cop_name}"
  end
  eol = Interface::Position.new(
    line: @offense.line - 1,
    character: length_of_line(@offense.source_line),
  )
  # TODO: fails for multiline strings - may be preferable to use block
  # comments to disable some offenses
  inline_comment = Interface::TextEdit.new(
    range: Interface::Range.new(start: eol, end: eol),
    new_text: new_text,
  )
  [inline_comment]
end