Skip to content

Commit

Permalink
Merge pull request #642 from jimnanney/neovim-10-code-actions-uri-fix
Browse files Browse the repository at this point in the history
Ensure returned uri from code actions contain a scheme
  • Loading branch information
searls committed Jul 16, 2024
2 parents 30fec01 + 2fcca8d commit 7a8ee6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
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?
!@offense.corrector.nil?
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

0 comments on commit 7a8ee6b

Please sign in to comment.