diff --git a/CHANGELOG.md b/CHANGELOG.md index 359779c52..fb86a4cd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 0.50.1 - Resolve self in yieldself tags +- Include absolute paths in config (#674) ## 0.50.0 - December 5, 2023 - Remove .travis.yml as its not longer used (#627) diff --git a/lib/solargraph/version.rb b/lib/solargraph/version.rb index 8af0f0496..62310a71c 100755 --- a/lib/solargraph/version.rb +++ b/lib/solargraph/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Solargraph - VERSION = '0.50.0' + VERSION = '0.50.1' end diff --git a/lib/solargraph/workspace/config.rb b/lib/solargraph/workspace/config.rb index effa6bdd7..0e66c585f 100644 --- a/lib/solargraph/workspace/config.rb +++ b/lib/solargraph/workspace/config.rb @@ -19,7 +19,7 @@ class Config # @param directory [String] def initialize directory = '' - @directory = directory + @directory = File.absolute_path(directory) @raw_data = config_data included excluded @@ -42,7 +42,8 @@ def excluded end def allow? filename - filename.start_with?(directory) && + filename = File.absolute_path(filename, directory) + filename.start_with?(directory) && !excluded.include?(filename) && excluded_directories.none? { |d| filename.start_with?(d) } end @@ -171,7 +172,7 @@ def default_config # @return [Array] def process_globs globs result = globs.flat_map do |glob| - Dir[File.join directory, glob] + Dir[File.absolute_path(glob, directory)] .map{ |f| f.gsub(/\\/, '/') } .select { |f| File.file?(f) } end @@ -186,7 +187,7 @@ def process_globs globs def process_exclusions globs remainder = globs.select do |glob| if glob_is_directory?(glob) - exdir = File.join(directory, glob_to_directory(glob)) + exdir = File.absolute_path(glob_to_directory(glob), directory) included.delete_if { |file| file.start_with?(exdir) } false else @@ -224,7 +225,7 @@ def glob_to_directory glob def excluded_directories @raw_data['exclude'] .select { |g| glob_is_directory?(g) } - .map { |g| File.join(directory, glob_to_directory(g)) } + .map { |g| File.absolute_path(glob_to_directory(g), directory) } end end end diff --git a/solargraph-0.50.0.gem b/solargraph-0.50.0.gem new file mode 100644 index 000000000..8c8f42ee9 Binary files /dev/null and b/solargraph-0.50.0.gem differ diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index 0ec80db9f..49d8a1aed 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -432,7 +432,7 @@ class Sup it "loads workspaces from directories" do api_map = Solargraph::ApiMap.load('spec/fixtures/workspace') - expect(api_map.source_map('spec/fixtures/workspace/app.rb')).to be_a(Solargraph::SourceMap) + expect(api_map.source_map(File.absolute_path('spec/fixtures/workspace/app.rb'))).to be_a(Solargraph::SourceMap) end it "finds constants from included modules" do diff --git a/spec/language_server/message/text_document/definition_spec.rb b/spec/language_server/message/text_document/definition_spec.rb index a12b9d138..72ff77f1e 100644 --- a/spec/language_server/message/text_document/definition_spec.rb +++ b/spec/language_server/message/text_document/definition_spec.rb @@ -4,10 +4,12 @@ host.prepare('spec/fixtures/workspace') sleep 0.1 until host.libraries.all?(&:mapped?) host.catalog + file_uri = Solargraph::LanguageServer::UriHelpers.file_to_uri(File.absolute_path('spec/fixtures/workspace/lib/other.rb')) + other_uri = Solargraph::LanguageServer::UriHelpers.file_to_uri(File.absolute_path('spec/fixtures/workspace/lib/thing.rb')) message = Solargraph::LanguageServer::Message::TextDocument::Definition.new(host, { 'params' => { 'textDocument' => { - 'uri' => 'file://spec/fixtures/workspace/lib/other.rb' + 'uri' => file_uri }, 'position' => { 'line' => 4, @@ -16,7 +18,7 @@ } }) message.process - expect(message.result.first[:uri]).to eq('file://spec/fixtures/workspace/lib/thing.rb') + expect(message.result.first[:uri]).to eq(other_uri) end it 'finds definitions of require paths' do