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

Keep the first line indentation selected when indenting text #1746

Open
evandrocoan opened this issue Jun 3, 2017 · 0 comments
Open

Keep the first line indentation selected when indenting text #1746

evandrocoan opened this issue Jun 3, 2017 · 0 comments

Comments

@evandrocoan
Copy link

@evandrocoan evandrocoan commented Jun 3, 2017

I am not sure if this is a bug. There is simple plugin posted by Stack Overflow#Keith Hall which changes this behavior:

import sublime
import sublime_plugin

class IndentSelectWholeFirstLineEventListener(sublime_plugin.EventListener):
    def on_post_text_command(self, view, command_name, args):
        if command_name == 'indent':
            if all(not sel.empty() for sel in view.sel()):
                if all(view.line(sel.begin()) != view.line(sel.end()) for sel in view.sel()):
                    new_selections = []
                    for sel in view.sel():
                        new_selections.append(sel.cover(view.line(sel.begin())))
                    view.sel().clear()
                    view.sel().add_all(new_selections)

Summary

Originally posted by BlueCaret:

I have an issue that is driving me insane with Sublime Text 3. When I select multiple lines by clicking on the side of the line and dragging, I then hit tab to correct the indentation, but then I want to move the entire line to another spot except I have to re-select it because the first line is only selected from where the text starts, not where the line starts.

Let's see if I can illustrate this... Below is the lines I have:

Text Line 1
Text Line 2

I select them (selection shown using *)

*Text Line 1
Text Line 2*

I indent the lines and now the selection looks like this:

    *Text Line1
    Text Line 2*

Notice the selection starts with the text. I want the selection to stay at the beginning of the line like this:

*   Text Line 1
    Text Line 2*

I have searched everywhere but apparently I'm the only one that is bothered by this. Every other code editor I have used does it the way I want.

https://stackoverflow.com/questions/24688117

Expected behavior

It is expected to the first indentation line to be part of the selection after the indentation process.

Actual behavior

The first line does not makes part of the selection after the indentation command.

Steps to reproduce

On this gif bellow I got some text unindented selected. Then I press tab to indent them. These are the tab commands:

    { "keys": ["tab"], "command": "reindent", "context":
        [
            { "key": "setting.auto_indent", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "preceding_text", "operator": "regex_match", "operand": "^$", "match_all": true },
            { "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true }
        ]
    },
    { "keys": ["tab"], "command": "indent", "context":
        [
            { "key": "text", "operator": "regex_contains", "operand": "\n" }
        ]
    },

Now the indentation created on the first line is out of the selection bounds after the indent command:

792693992567b0123aa6bd2c4be1ae3b96a1abcb

Then I have to select them manually later, after the indentation.

Text used:

$ ls F:\Python36\lib\site-packages\matplotlib
__init__.py               _mathtext_data.py    animation.py       blocking_input.py  ...
_contour.cp36-win32.pyd   _version.py          backend_tools.py   compat             ...
_delaunay.cp36-win32.pyd...                    mathtext.py        pyplot.py...
_image.cp36-win32.pyd     afm.py               bezier.py          contour.py         ...
...

Steps originally posted on:

  1. $28741 How to keep the first line indentation selected when indenting?

Environment

  • Operating system and version:
    • Windows 10 build 15063 (x64)
    • Mac OS ...
    • Linux ...
  • Monitor:
    • Resolution 1920x1080
    • dpi_scale used in ST 1.0
  • Sublime Text:
    • Build 3133
    • 32 bit (x86)
evandrocoan added a commit to evandrocoan/ITE that referenced this issue Jun 3, 2017
selected when indenting with tab.

Issue:
#1746 Keep the first line indentation selected when indenting text
sublimehq/sublime_text#1746
evandrocoan added a commit to evandrocoan/ITE that referenced this issue Jun 19, 2017
selected when indenting with tab.

Issue:
#1746 Keep the first line indentation selected when indenting text
sublimehq/sublime_text#1746
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.