Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add wrap lines action in Source menu and shortcut for it #20090

Open
wants to merge 2 commits into
base: 5.x
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@
'editor/close split panel': "Alt+Shift+W",
'editor/docstring': "Ctrl+Alt+D",
'editor/autoformatting': "Ctrl+Alt+I",
'editor/wrap lines': "Alt+Z",
'editor/show in external file explorer': '',
# -- Internal console --
'console/inspect current object': "Ctrl+I",
Expand Down
17 changes: 14 additions & 3 deletions spyder/plugins/editor/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,10 @@ def get_plugin_actions(self):
_("Underline errors and warnings"),
'underline_errors', 'set_underline_errors_enabled')

wrap_lines_action = self._create_checkable_action(
_("Wrap lines"), 'wrap', 'set_wrap_enabled',
shortcut=CONF.get_shortcut('editor', 'wrap lines'))

self.checkable_actions = {
'blank_spaces': showblanks_action,
'scroll_past_end': scrollpastend_action,
Expand All @@ -958,7 +962,8 @@ def get_plugin_actions(self):
'show_class_func_dropdown': show_classfunc_dropdown_action,
'pycodestyle': show_codestyle_warnings_action,
'pydocstyle': show_docstring_warnings_action,
'underline_errors': underline_errors}
'underline_errors': underline_errors,
'wrap': wrap_lines_action}

fixindentation_action = create_action(self, _("Fix indentation"),
tip=_("Replace tab characters by space characters"),
Expand Down Expand Up @@ -1172,6 +1177,7 @@ def get_plugin_actions(self):
show_codestyle_warnings_action,
show_docstring_warnings_action,
underline_errors,
wrap_lines_action,
MENU_SEPARATOR,
self.todo_list_action,
self.warning_list_action,
Expand Down Expand Up @@ -1354,7 +1360,12 @@ def set_ancestor(self, ancestor):
except RuntimeError:
pass

def _create_checkable_action(self, text, conf_name, method=''):
def _create_checkable_action(
self,
text,
conf_name,
method='',
shortcut=None):
"""Helper function to create a checkable action.

Args:
Expand All @@ -1368,7 +1379,7 @@ def toogle(checked):
self.switch_to_plugin()
self._toggle_checkable_action(checked, method, conf_name)

action = create_action(self, text, toggled=toogle)
action = create_action(self, text, toggled=toogle, shortcut=shortcut)
action.blockSignals(True)

if conf_name not in ['pycodestyle', 'pydocstyle']:
Expand Down
Loading