Sha256: 73c0d41bb5f4a2121307ec2fec56760045d62eddf54f3b2834b78030cdac830b

Contents?: true

Size: 621 Bytes

Versions: 43

Compression:

Stored size: 621 Bytes

Contents

# frozen_string_literal: true

module ThemeCheck
  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)
        return content.match(WORD)[0] if content.match?(WORD)
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
theme-check-1.5.2 lib/theme_check/language_server/completion_helper.rb
theme-check-1.5.1 lib/theme_check/language_server/completion_helper.rb
theme-check-1.5.0 lib/theme_check/language_server/completion_helper.rb
theme-check-1.4.0 lib/theme_check/language_server/completion_helper.rb
theme-check-1.3.0 lib/theme_check/language_server/completion_helper.rb
theme-check-1.2.0 lib/theme_check/language_server/completion_helper.rb
theme-check-1.1.0 lib/theme_check/language_server/completion_helper.rb
theme-check-1.0.0 lib/theme_check/language_server/completion_helper.rb
theme-check-0.10.2 lib/theme_check/language_server/completion_helper.rb
theme-check-0.10.1 lib/theme_check/language_server/completion_helper.rb
theme-check-0.10.0 lib/theme_check/language_server/completion_helper.rb
theme-check-0.9.1 lib/theme_check/language_server/completion_helper.rb
theme-check-0.9.0 lib/theme_check/language_server/completion_helper.rb
theme-check-0.8.3 lib/theme_check/language_server/completion_helper.rb
theme-check-0.8.2 lib/theme_check/language_server/completion_helper.rb
theme-check-0.8.1 lib/theme_check/language_server/completion_helper.rb
theme-check-0.8.0 lib/theme_check/language_server/completion_helper.rb
theme-check-0.7.3 lib/theme_check/language_server/completion_helper.rb
theme-check-0.7.2 lib/theme_check/language_server/completion_helper.rb
theme-check-0.7.1 lib/theme_check/language_server/completion_helper.rb