ruby-lsp-typeprof 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b0dc266b02ba9428bd88e6001b094436c17fe94407477e1e2f184825416a40a
4
- data.tar.gz: 70fa07a521a222f5c9e1ac9a62e2458bd41308b1eb6559a7252d8cfe8298008c
3
+ metadata.gz: 8dca9c586f41117ed848a69f9f2745e6e37b62248ddd4624a0af1b8f0de55962
4
+ data.tar.gz: c36003ffa4f755bf22f6942c98b7d09b0e9b0499886e85f0a6bed61742c9f812
5
5
  SHA512:
6
- metadata.gz: 4ed5ddf9b0a88bd9ad17fa748225ad62d23b1ab5e99f181b21a5dea1f10c2fecab850403c39470447487550b11f7a03989b648f7d61aa8ab586b5f8b75d5d50c
7
- data.tar.gz: 33ea5a60eeb2295adff2ad7f73828d17dabe17cbcc01be64209bca361e8bb8bcd36f61f5b6e84a40601be2e9299817652dae9915024f90a8c6738d1447cdf1c7
6
+ metadata.gz: 94b3aec43190e38cf7d175b75be234ad8bba724326b46a03eff867bf337a400ac62647fa09cfa4edcc2a54572106b5a366d9796a015e2f60f417cd18f0ca2c5e
7
+ data.tar.gz: 9aa30927f54947bcad1ae814ac353c448a4dfd9c38878e94b6cb3685e38fa677cd760adff8b8e2a23a7658845a9f0046d511c8d94a16b2abcfd41d4a9f93bba8
@@ -30,7 +30,7 @@ module RubyLsp
30
30
  return unless @enabled
31
31
 
32
32
  require "typeprof"
33
- @service = build_service(global_state.workspace_path)
33
+ @service = with_utf8_default_external { build_service(global_state.workspace_path) }
34
34
  rescue StandardError => e
35
35
  log_error("Ruby LSP TypeProf failed to activate: #{e.full_message(highlight: false)}")
36
36
  end
@@ -109,10 +109,25 @@ module RubyLsp
109
109
  path = URI.parse(change[:uri]).path
110
110
  return unless path&.end_with?(".rb", ".rbs")
111
111
 
112
- @service.update_file(path, nil)
112
+ with_utf8_default_external { @service.update_file(path, nil) }
113
113
  rescue StandardError => e
114
114
  log_error("Ruby LSP TypeProf failed to update file #{path}: #{e.full_message(highlight: false)}")
115
115
  end
116
+
117
+ # TypeProf reads files with File.read, which follows Encoding.default_external.
118
+ # Without LANG that is US-ASCII and non-ASCII .rbs files fail to parse.
119
+ # See ruby/typeprof#479.
120
+ def with_utf8_default_external
121
+ orig = Encoding.default_external
122
+ return yield if orig == Encoding::UTF_8
123
+
124
+ Encoding.default_external = Encoding::UTF_8
125
+ begin
126
+ yield
127
+ ensure
128
+ Encoding.default_external = orig
129
+ end
130
+ end
116
131
  end
117
132
  end
118
133
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyLsp
4
4
  module Typeprof
5
- VERSION = "0.5.0"
5
+ VERSION = "0.5.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp-typeprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takumi Shotoku
@@ -61,7 +61,7 @@ licenses:
61
61
  - MIT
62
62
  metadata:
63
63
  homepage_uri: https://github.com/sinsoku/ruby-lsp-typeprof
64
- source_code_uri: https://github.com/sinsoku/ruby-lsp-typeprof/tree/v0.5.0
64
+ source_code_uri: https://github.com/sinsoku/ruby-lsp-typeprof/tree/v0.5.1
65
65
  changelog_uri: https://github.com/sinsoku/ruby-lsp-typeprof/releases
66
66
  rubygems_mfa_required: 'true'
67
67
  rdoc_options: []