diff --git a/pylsp_rope/refactoring.py b/pylsp_rope/refactoring.py index be15953..31d3b4e 100644 --- a/pylsp_rope/refactoring.py +++ b/pylsp_rope/refactoring.py @@ -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) diff --git a/test/test_inline.py b/test/test_inline.py index 8f5cc63..8106eb6 100644 --- a/test/test_inline.py +++ b/test/test_inline.py @@ -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, + )