Sublime Forum

Add a warning when multi-selecting invisible text

#1

This is a small feature request:

Once in a while, I’ll multi-select a few fields, and accidently select some off-screen text (that appears later/earlier in the view). This usually happens because I didn’t notice that some phrase appears more than twice in my document.
Whenever this happens, I make lots of changes, then realize that some other part of the file is ruined.

I’m thinking, just add a tiny “warning balloon” that appears at the top-right corner of the view, which lets you know that text was selected off-screen.

(In fact, if you could expose an API to set the text of the balloon, I could think of several other uses for it).

0 Likes

#2

You can see the number of selections in the statusbar, and the minimap is also of great help to see where the other selections are.

This being said, here’s a plugin that will deselect anything that is not currently visible:

[code]import sublime, sublimeplugin

class CropVisibleSelectionCommand(sublimeplugin.TextCommand):
def run(self, view, args):
mask1 = sublime.Region(0, view.visibleRegion().begin())
mask2 = sublime.Region(view.visibleRegion().end(), view.size())
view.sel().subtract(mask1)
view.sel().subtract(mask2)
[/code]

Using view.visibleRegion(), you could create a plugin that warns you about how many selections are currently hidden, or something like that.

0 Likes

#3

… like this:

[code]import sublime, sublimeplugin

class HiddenSelectionInfo(sublimeplugin.Plugin):
def onSelectionModified(self, view):
hidden = 0
visible = view.visibleRegion()
for region in view.sel():
if not region.intersects(visible):
hidden += 1

	if hidden >	0:
		view.setStatus('hiddenRegions', "%i hidden region%s" % (hidden, 's' if hidden > 1 else ''))
	else:
		view.eraseStatus('hiddenRegions')

[/code]

0 Likes

#4

Yeah, I know that you can use the status bar to display messages.

But, to me at least, that doesn’t seem intrusive enough.
It’s always there, and it doesn’t grab your attention when it needs you to know something.

I have a vivid imagination of a “message box” that can be display in any view, which pops up for a few seconds and then closes, and which carries important information (something like the Gmail status messages you get when you delete mails, for example).

Then, the editor could help new users by popping up helpful messages whenever they do something that might warrant more explanation.
For example, the first time someone does a multi-selection (which is going to be new to most people), the message box can pop up and say “You made a multi-selection. For more info, click here” or something along those lines.

Anyway, that’s just a dream of mine for an editor that actually helps the users learn all its awesome features.

0 Likes

#5

I agree: modal alert boxes are too intrusive, so I tend to open/close the console pane all the time, bad habit.

+1 for modeless alerts!

0 Likes

#6

One way this could be solved without the need for alerts is to “throb” all selected regions in the minimap.

Right now, selected regions in the minimap are indicated by a static solid colour, which can be easily overlooked if your colour scheme contains lots of different colours itself. The eye is attracted first to movement, and second to changes in luminosity. So if the selected regions faded gently from (for example) white to grey to white again, seeing all the selections in the document would be very much easier.

Cool idea or no?

0 Likes

#7

Actually yeah, that’s a great idea.
I’ll just add that making the cursor itself (i.e. one selection) blink as well would also be very welcome, since I sometimes have a little trouble finding it on the minimap.

I still think a cool message api is good for really grabbing someone’s attention in other cases, though.

Guess there’s lots more to do for the next Sublime versions :smile:

0 Likes