Skip to content

Commit 6758afa

Browse files
committed
(maint) Fix parsing at beginning of a document
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.
1 parent 8e3dc41 commit 6758afa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/puppet-languageserver/puppet_parser_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ def self.object_under_cursor(content, line_num, char_num, multiple_attempts = fa
7272
when :noop
7373
new_content = content
7474
when :remove_char
75+
next if line_num.zero? && char_num.zero?
7576
new_content = remove_char_at(content, line_offsets, line_num, char_num)
7677
move_offset = -1
7778
when :remove_word
79+
next if line_num.zero? && char_num.zero?
7880
next_char = get_char_at(content, line_offsets, line_num, char_num)
7981

8082
while /[[:word:]]/ =~ next_char

0 commit comments

Comments
 (0)