Skip to content

Commit

Permalink
(maint) Fix parsing at beginning of a document
Browse files Browse the repository at this point in the history
Previously the parser helper was silently failing to parse documents
that had the cursor at line 0, char 0. This was due to the
removal based methods trying to remove characters at the beginning
of the document.  This commit modifies the helper to ignore these
parsing attempts if the cursor is at line 0, char 0.
  • Loading branch information
glennsarti committed Jan 20, 2019
1 parent 8e3dc41 commit 6758afa
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/puppet_parser_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ def self.object_under_cursor(content, line_num, char_num, multiple_attempts = fa
when :noop
new_content = content
when :remove_char
next if line_num.zero? && char_num.zero?
new_content = remove_char_at(content, line_offsets, line_num, char_num)
move_offset = -1
when :remove_word
next if line_num.zero? && char_num.zero?
next_char = get_char_at(content, line_offsets, line_num, char_num)

while /[[:word:]]/ =~ next_char
Expand Down

0 comments on commit 6758afa

Please sign in to comment.