Sha256: 3f4f7884d125f054065c9b552906f882ad26012855c2f1cccf80bd3e57ff597d

Contents?: true

Size: 620 Bytes

Versions: 25

Compression:

Stored size: 620 Bytes

Contents

# frozen_string_literal: true

module PlatformosCheck
  module LanguageServer
    module CompletionHelper
      WORD = /\w+/

      def cursor_on_start_content?(content, cursor, regex)
        content.slice(0, cursor).match?(/#{regex}(?:\s|\n)*$/m)
      end

      def cursor_on_first_word?(content, cursor)
        word = content.match(WORD)
        return false if word.nil?

        word_start = word.begin(0)
        word_end = word.end(0)
        word_start <= cursor && cursor <= word_end
      end

      def first_word(content)
        content.match(WORD)[0] if content.match?(WORD)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
platformos-check-0.4.14 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.13 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.12 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.11 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.10 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.9 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.8 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.7 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.6 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.5 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.4 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.3 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.2 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.1 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.4.0 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.3.3 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.3.1 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.3.0 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.2.2 lib/platformos_check/language_server/completion_helper.rb
platformos-check-0.2.1 lib/platformos_check/language_server/completion_helper.rb