kek / sublime-expand-selection-to-quotes

Sublime Text plugin to expand selection to surrounding quotes
107 stars 13 forks source link

Added backticks to single and double quotes, plus some refactoring #14

Closed MattDMo closed 3 years ago

MattDMo commented 4 years ago

I added the ability to expand to Markdown backticks ` as well as single and double quotes. I also did a little refactoring, moving the function definitions for search_for_quotes() and replace_region() outside the for loop, so new function objects aren't created each time through the loop.

Here's the test I used to make sure the logic was correct:

test_values = [(3, 0, 0), # d_size, s_size, b_size
               (0, 3, 0),
               (0, 0, 3),
               (3, 1, 2),
               (1, 3, 2),
               (1, 2, 3),
               (3, 2, 1),
               (2, 3, 1),
               (2, 1, 3),
               ]

for values in test_values:
    d_size, s_size, b_size = values
    print(values)
    if d_size and (not s_size or d_size < s_size) and (not b_size or d_size < b_size):
        print("d block is True")
    else: print("d block is False")
    if s_size and (not d_size or s_size < d_size) and (not b_size or s_size < b_size):
        print("s block is True")
    else: print("s block is False")
    if b_size and (not d_size or b_size < d_size) and (not s_size or b_size < s_size):
        print("b block is True")
    else: print("b block is False")

It should be True where there's a 3, and False everywhere else.

Let me know if you have any questions.

alexanderankin commented 3 years ago

actually it would have been ideal to have the whitespace preserved so that the changes are clear.

MattDMo commented 3 years ago

Sorry, I'm not following. Which whitespace would you like to have preserved?

MattDMo commented 3 years ago

Sorry, I'm dumb. I'm guessing you mean the tab spacing? I can do that if you prefer.

MattDMo commented 3 years ago

OK, should be all set now.

alexanderankin commented 3 years ago

sorry i just meant that for the benefit of @kek , so that he can merge them

fbzoltan commented 3 years ago

Hello, would be possible to select html tag text, for example Hello World in <span>Hello World</span> ? Thank you, Z

fbzoltan commented 3 years ago

I was told on sublime forum: Ctrl + Shift + A :)

kek commented 3 years ago

Thanks for the PR @MattDMo .

Perhaps late is better than never :sweat_smile:

kek commented 3 years ago

@MattDMo Was there any special reason to convert indentation to tabs? https://www.python.org/dev/peps/pep-0008/ seems to recommend using spaces.

alexanderankin commented 2 years ago

thank you so so much!!!