class RubyLsp::Requests::SelectionRanges
Note that if using VSCode Neovim, you will need to be in Insert mode for this to work correctly.
Trigger this request with: Ctrl + Shift + -> or Ctrl + Shift + <-
of their cursor(s).
request informs the editor of ranges that the user may want to select based on the location(s)
The [selection ranges](microsoft.github.io/language-server-protocol/specification#textDocument_selectionRange)
def initialize(document)
def initialize(document) super() @document = document @ranges = [] #: Array[Support::SelectionRange] @stack = [] #: Array[Support::SelectionRange] end
def perform
@override
def perform # [node, parent] queue = [[@document.ast, nil]] until queue.empty? node, parent = queue.shift next unless node range = Support::SelectionRange.new(range: range_from_location(node.location), parent: parent) queue.unshift(*node.child_nodes.map { |child| [child, range] }) @ranges.unshift(range) end @ranges end