summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2026-01-27 21:20:48 +0100
committergit <svn-admin@ruby-lang.org>2026-01-27 20:49:02 +0000
commit5c15f9380f9782750ee223140108950a5262075e (patch)
tree720eb5612e27d027fc361f6725a3384bf500dd07 /lib
parent1cd32536a56adc81e3a0f861ad43e5aaf8457a28 (diff)
[ruby/prism] Use the terminology "column in bytes/characters/code units"
* Consistent and clear. * Avoids the confusion that "column number" might be understood as a column in an editor starting at 1 (they all start at 0). https://github.com/ruby/prism/commit/91f1c4b9d5
Diffstat (limited to 'lib')
-rw-r--r--lib/prism/parse_result.rb20
-rw-r--r--lib/prism/translation/ripper.rb2
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/prism/parse_result.rb b/lib/prism/parse_result.rb
index be1c13f97c..2498ae7e14 100644
--- a/lib/prism/parse_result.rb
+++ b/lib/prism/parse_result.rb
@@ -103,7 +103,7 @@ module Prism
offsets[find_line(byte_offset) + 1] || source.bytesize
end
- # Return the column number for the given byte offset.
+ # Return the column in bytes for the given byte offset.
def column(byte_offset)
byte_offset - line_start(byte_offset)
end
@@ -113,7 +113,7 @@ module Prism
(source.byteslice(0, byte_offset) or raise).length
end
- # Return the column number in characters for the given byte offset.
+ # Return the column in characters for the given byte offset.
def character_column(byte_offset)
character_offset(byte_offset) - character_offset(line_start(byte_offset))
end
@@ -146,7 +146,7 @@ module Prism
CodeUnitsCache.new(source, encoding)
end
- # Returns the column number in code units for the given encoding for the
+ # Returns the column in code units for the given encoding for the
# given byte offset.
def code_units_column(byte_offset, encoding)
code_units_offset(byte_offset, encoding) - code_units_offset(line_start(byte_offset), encoding)
@@ -253,7 +253,7 @@ module Prism
byte_offset
end
- # Return the column number in characters for the given byte offset.
+ # Return the column in characters for the given byte offset.
def character_column(byte_offset)
byte_offset - line_start(byte_offset)
end
@@ -428,19 +428,19 @@ module Prism
source.line(end_offset)
end
- # The column number in bytes where this location starts from the start of
+ # The column in bytes where this location starts from the start of
# the line.
def start_column
source.column(start_offset)
end
- # The column number in characters where this location ends from the start of
+ # The column in characters where this location ends from the start of
# the line.
def start_character_column
source.character_column(start_offset)
end
- # The column number in code units of the given encoding where this location
+ # The column in code units of the given encoding where this location
# starts from the start of the line.
def start_code_units_column(encoding = Encoding::UTF_16LE)
source.code_units_column(start_offset, encoding)
@@ -452,19 +452,19 @@ module Prism
cache[start_offset] - cache[source.line_start(start_offset)]
end
- # The column number in bytes where this location ends from the start of the
+ # The column in bytes where this location ends from the start of the
# line.
def end_column
source.column(end_offset)
end
- # The column number in characters where this location ends from the start of
+ # The column in characters where this location ends from the start of
# the line.
def end_character_column
source.character_column(end_offset)
end
- # The column number in code units of the given encoding where this location
+ # The column in code units of the given encoding where this location
# ends from the start of the line.
def end_code_units_column(encoding = Encoding::UTF_16LE)
source.code_units_column(end_offset, encoding)
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb
index 70f72132f6..ccce226d7d 100644
--- a/lib/prism/translation/ripper.rb
+++ b/lib/prism/translation/ripper.rb
@@ -475,7 +475,7 @@ module Prism
# The current line number of the parser.
attr_reader :lineno
- # The current column number of the parser.
+ # The current column in bytes of the parser.
attr_reader :column
# Create a new Translation::Ripper object with the given source.