Sha256: ad28b7920920fec28d68cee6fd8aaa4f3c3f67429fc0097a01a46fc17c44cdda
Contents?: true
Size: 590 Bytes
Versions: 8
Compression:
Stored size: 590 Bytes
Contents
# frozen_string_literal: true # Note: Everything is 0-indexed here. module ThemeCheck module LanguageServer module PositionHelper def from_line_column_to_index(content, row, col) i = 0 result = 0 lines = content.lines while i < row result += lines[i].size i += 1 end result += col result end def from_index_to_line_column(content, index) lines = content[0..index].lines row = lines.size - 1 col = lines.last.size - 1 [row, col] end end end end
Version data entries
8 entries across 8 versions & 1 rubygems