Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure returned uri from code actions contain a scheme #642

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/standard/lsp/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def autocorrect_action
document_changes: [
Interface::TextDocumentEdit.new(
text_document: Interface::OptionalVersionedTextDocumentIdentifier.new(
uri: @uri.to_s,
uri: ensure_uri_scheme(@uri.to_s).to_s,
version: nil
),
edits: correctable? ? offense_replacements : []
Expand Down Expand Up @@ -113,7 +113,7 @@ def disable_line_action
document_changes: [
Interface::TextDocumentEdit.new(
text_document: Interface::OptionalVersionedTextDocumentIdentifier.new(
uri: @uri.to_s,
uri: ensure_uri_scheme(@uri.to_s).to_s,
version: nil
),
edits: line_disable_comment
Expand Down Expand Up @@ -163,6 +163,12 @@ def length_of_line(line)
def correctable?
[email protected]?
end

def ensure_uri_scheme(uri)
uri = URI.parse(uri)
uri.scheme = "file" if uri.scheme.nil?
uri
end
end
end
end
12 changes: 6 additions & 6 deletions test/standard/runners/lsp_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_did_open
edit: {
documentChanges: [
{
textDocument: {uri: "/path/to/file.rb", version: nil},
textDocument: {uri: "file:///path/to/file.rb", version: nil},
edits: [
{
range: {
Expand All @@ -84,7 +84,7 @@ def test_did_open
edit: {
documentChanges: [
{
textDocument: {uri: "/path/to/file.rb", version: nil},
textDocument: {uri: "file:///path/to/file.rb", version: nil},
edits: [
{
range: {
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_did_open
edit: {
documentChanges: [
{
textDocument: {uri: "/path/to/file.rb", version: nil},
textDocument: {uri: "file:///path/to/file.rb", version: nil},
edits: [
{
range: {
Expand All @@ -139,7 +139,7 @@ def test_did_open
edit: {
documentChanges: [
{
textDocument: {uri: "/path/to/file.rb", version: nil},
textDocument: {uri: "file:///path/to/file.rb", version: nil},
edits: [
{
range: {
Expand Down Expand Up @@ -176,7 +176,7 @@ def test_did_open
edit: {
documentChanges: [
{
textDocument: {uri: "/path/to/file.rb", version: nil},
textDocument: {uri: "file:///path/to/file.rb", version: nil},
edits: [
{
range: {
Expand All @@ -196,7 +196,7 @@ def test_did_open
edit: {
documentChanges: [
{
textDocument: {uri: "/path/to/file.rb", version: nil},
textDocument: {uri: "file:///path/to/file.rb", version: nil},
edits: [
{
range: {
Expand Down