Skip to content

Commit

Permalink
Use toggle block style for code action instead of switch
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Aug 12, 2024
1 parent 377fb95 commit 615c2d1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/ruby_lsp/requests/code_action_resolve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def perform
refactor_variable
when CodeActions::EXTRACT_TO_METHOD_TITLE
refactor_method
when CodeActions::SWITCH_BLOCK_STYLE_TITLE
when CodeActions::TOGGLE_BLOCK_STYLE_TITLE
switch_block_style
else
Error::UnknownCodeAction
Expand All @@ -81,7 +81,7 @@ def switch_block_style
indentation = " " * target.location.start_column unless node.opening_loc.slice == "do"

Interface::CodeAction.new(
title: CodeActions::SWITCH_BLOCK_STYLE_TITLE,
title: CodeActions::TOGGLE_BLOCK_STYLE_TITLE,
edit: Interface::WorkspaceEdit.new(
document_changes: [
Interface::TextDocumentEdit.new(
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby_lsp/requests/code_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CodeActions < Request

EXTRACT_TO_VARIABLE_TITLE = "Refactor: Extract Variable"
EXTRACT_TO_METHOD_TITLE = "Refactor: Extract Method"
SWITCH_BLOCK_STYLE_TITLE = "Refactor: Switch block style"
TOGGLE_BLOCK_STYLE_TITLE = "Refactor: Toggle block style"

class << self
extend T::Sig
Expand Down Expand Up @@ -71,7 +71,7 @@ def perform
data: { range: @range, uri: @uri.to_s },
)
code_actions << Interface::CodeAction.new(
title: SWITCH_BLOCK_STYLE_TITLE,
title: TOGGLE_BLOCK_STYLE_TITLE,
kind: Constant::CodeActionKind::REFACTOR_REWRITE,
data: { range: @range, uri: @uri.to_s },
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"params": {
"kind": "refactor.rewrite",
"title": "Refactor: Switch block style",
"title": "Refactor: Toggle block style",
"data": {
"range": {
"start": {
Expand All @@ -17,7 +17,7 @@
}
},
"result": {
"title": "Refactor: Switch block style",
"title": "Refactor: Toggle block style",
"edit": {
"documentChanges": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"params": {
"kind": "refactor.rewrite",
"title": "Refactor: Switch block style",
"title": "Refactor: Toggle block style",
"data": {
"range": {
"start": {
Expand All @@ -17,7 +17,7 @@
}
},
"result": {
"title": "Refactor: Switch block style",
"title": "Refactor: Toggle block style",
"edit": {
"documentChanges": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"params": {
"kind": "refactor.rewrite",
"title": "Refactor: Switch block style",
"title": "Refactor: Toggle block style",
"data": {
"range": {
"start": {
Expand All @@ -17,7 +17,7 @@
}
},
"result": {
"title": "Refactor: Switch block style",
"title": "Refactor: Toggle block style",
"edit": {
"documentChanges": [
{
Expand Down
2 changes: 1 addition & 1 deletion test/expectations/code_actions/aref_field.exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}
},
{
"title": "Refactor: Switch block style",
"title": "Refactor: Toggle block style",
"kind": "refactor.rewrite",
"data": {
"range": {
Expand Down

0 comments on commit 615c2d1

Please sign in to comment.