-
Notifications
You must be signed in to change notification settings - Fork 67
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
editor.getUserLineSelection() and editor.getUserCharSelection() should allow other defaults if empty selection #304
Comments
To avoid corrupting existing code, a third parameter such as |
@Ekopalypse , what I suggested in my EDIT above would be clearer (I've added now there Also, considering current line is, again, just one possibility. User might want to just do nothing if selection is empty -- and to tell that selection is empty, the returned values should correspond to empty selection, not for a line. |
@victorel-petrovich We seem to have a different view in general about what a user can expect. For me, functions can/should only provide what they are supposed to do and what is documented. If I use getUserLineSelection and it is documented that it acts on the entire document, if nothing is selected, then so be it. There is a getSelectionEmpty function to find out if there is a selection. I agree that it is not intuitive to use the entire document when nothing is selected if we were to introduce this as a new function, but since it was introduced this way and, more importantly, it was documented, I tend to say that it should not be changed. Personally, I think it's better to introduce a new parameter that also does new things instead of confirming old things that have always been done ... but these are personal preferences. Just to avoid confusion, I don't care in the end what the parameter is called, the only important thing from my point of view is that existing code still runs after a change. |
Yes, that was clear from your first comment.
Fact ! :)
-- what the function is supposed to do: which is simply to return the But it can be documented as well, if you say that is not self-evident. And, as I mentioned, the other advantage IMO is that it's more general; it leaves up to the user to decide whether to consider current line or current word something else entirely in case
👍 |
On a bit more thinking on what could be reasonable to return when selection is empty: While for For
This will allow extending the function when users find the need, to say a 3rd value: 1, to return start and end pos. of current line |
To this whole idea, I say: Why not assume the whole document? In Notepad++ (disregarding PythonScript entirely), if you use the line sorting functions without having a certain set of selected lines, what happens? The entire document gets sorted. So...there is some precedent for the way this PS function works. And the logic of it is "not bad". And it is well-documented. And, as was pointed out, IMO, don't fix what isn't broken. Also, don't complicate what isn't broken. |
I already brought arguments for why , from beginning.
But what happens if you use delete operation? Or if you use On selection > Search on Internet? etc
Too early to conclude how many are for or against. |
These are not line-based operations.
Not really -- the current functionality has been in place for a long time with no complainers. |
That's partly the point, it doesn't have to be about line-based operation (however you define them). I really meant how many for/against the Issue I made. |
You've probably gotten all the people that will "vote" already. |
Have you really encountered "problems" with the way these functions are through writing scripts and being surprised by the functionality? You strike me as someone that is just going along and reading the API and finding things to complain about. We get such complainers here occasionally; not sure where such behavior originates... Anyway, you'll get responses from those such as @Ekopalypse and myself, but the maintainer of PythonScript (@chcg) and even Notepad++ (Don Ho) won't bite, and they will probably just put the big REJECT on your ideas. BTW, your idea is not terrible, but the time to implement it would have been with the first incarnation of the function. Subsequent to that, it's a big "who cares?", and other scripting constructs are used to avoid the "whole doc" functionality when desired, as previously mentioned. It's simply not important enough to change, even with the idea of another argument. |
Not complaining, but striving for improvement, wherever possible. What's weird is that you're soo insistent in fighting this issue, as if the particular matter here is that important to you.
I'm not worried about that.
Exactly. Then why don't you just ignore it as well... |
My goal in commenting in this issue is simply to "vote" (express my opinion). I'm only "fighting" it because it isn't a necessary thing. If it gets implemented, I'm not going to be unduly upset. But I'd rather the devs spend their volunteer time on other things. And...if people stay silent, a rogue person could drive a bad change (that's "in general", not specific to this one) -- this has happened. It's not personal, of course. If you have good ideas, I'll let you know; same for what I consider bad ideas (obviously). Good idea example: the Scintilla imbalance with selection line delete (took me a bit of time to understand, though).
Well, this makes me feel good. :-) I do think scripting fills a void. Everyone wants their great idea for Notepad++ to be implemented natively, but I certainly don't agree with that, and scripting can be perfect for that situation. So I like writing and sharing scripts and helping others with them. I think I've probably written more scripts than anyone else, although @Ekopalypse is the script-master, writing way more advanced scripts than I could ever hope to. OK, ignoring from now on... |
... because it's not always the case that the whole document is needed if nothing is selected. For example, current line could be considered instead.
So I suggest for these functions to instead return same values for
startLine, endLine
andstartByte, endByte
, corresponding to the current position of the caret.Then code could decide what to do next.
EDIT: or, at least, provide an optional 3rd argument,
wholeDocIfEmptySel=True
, boolean.Thanks.
The text was updated successfully, but these errors were encountered: