Skip to content

Commit

Permalink
Update plugin/documents.py
Browse files Browse the repository at this point in the history
Co-authored-by: Rafał Chłodnicki <[email protected]>
  • Loading branch information
predragnikolic and rchl authored Jan 29, 2024
1 parent 6850d20 commit 4346bae
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugin/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,11 +527,12 @@ def on_text_command(self, command_name: str, args: Optional[dict]) -> Optional[T
session = self.session_async("semanticTokensProvider")
if session:
return ("lsp_show_scope_name", {})
elif command_name == 'paste_and_indent' and format_on_paste:
elif command_name == 'paste_and_indent'
# if `lsp_format_on_paste` is enabled and paste_and_indent is run,
# it is easier to find the region to format when `paste` is invoked,
# so we intercept the `paste_and_indent` and replace it with the `paste` command.
if self.session_async("documentRangeFormattingProvider"):
format_on_paste = self.view.settings().get('lsp_format_on_paste', userprefs().lsp_format_on_paste):
if format_on_paste and self.session_async("documentRangeFormattingProvider"):
return ('paste', {})
return None

Expand Down

0 comments on commit 4346bae

Please sign in to comment.