Skip to content
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
5 changes: 4 additions & 1 deletion pylsp_rope/refactoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,14 @@ class CommandRefactorInline(Command):
position: typing.Range

def validate(self, info):
inline.create_inline(
refactoring = inline.create_inline(
project=self.project,
resource=info.resource,
offset=info.current_document.offset_at_position(info.position),
)
rope_changeset = refactoring.get_changes()
if not rope_changeset.changes:
raise Exception("Not offering changeless inline refactor")

def get_changes(self):
current_document, resource = get_resource(self.workspace, self.document_uri)
Expand Down
22 changes: 22 additions & 0 deletions test/test_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,25 @@ def test_inline_not_offered_when_selecting_unsuitable_range(
response,
command=commands.COMMAND_REFACTOR_INLINE,
)


def test_inline_not_offered_when_selecting_function_parameter(
config, workspace, code_action_context
):
document = create_document(workspace, "simple_extract_method.py")
line = 10
start_col = end_col = document.lines[line].index("a")
selection = Range((line, start_col), (line, end_col))

response = plugin.pylsp_code_actions(
config=config,
workspace=workspace,
document=document,
range=selection,
context=code_action_context,
)

assert_code_actions_do_not_offer(
response,
command=commands.COMMAND_REFACTOR_INLINE,
)