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
Fixes & changes for #1470 #1554
Conversation
src/editor.c
Outdated
@@ -2458,7 +2457,7 @@ void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gint inser | |||
gint line_start = sci_get_line_from_position(sci, insert_pos); | |||
GString *buf; | |||
const gchar *eol = editor_get_eol_char(editor); | |||
gint idx; | |||
gint idx = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure this is the Right Fix™, and I didn't test it thoroughly enough. @kugel- you might know better than I do maybe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at it more closely, the issue is more serious, and your fix seems insufficient. I'll look into it.
I wonder why I didn't see any warnings. I understand that my CFLAGS may not be pedantic enough for the unused variables, but I should have seen the uninitialized access one. |
See #1561 |
dcea941
to
e7cd97f
Compare
@@ -2394,7 +2394,7 @@ typedef struct | |||
} SelectionRange; | |||
|
|||
|
|||
#define CURSOR_PLACEHOLDER "_" /* Would rather use … but not all docs are unicode */ | |||
#define CURSOR_PLACEHOLDER "..." /* Would rather use … but not all docs are unicode */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S/A 957b49b#comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the resolution on this? Still not a fan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use Unicode ellipsis? All documents are UTF-8 in memory and since placeholders markers shouldn't ever be saved (they aren't actual contents of the document), it seems like it would work fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had that before. Since nothing prevents you from saving a doc containing the placeholders, I didn't want to enforce utf8 for saved files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the placeholders not be saved since they aren't meant to be literally inserted into the document? IIRC other editors I've tried that do this (namely XCode and QtCreator) don't treat placeholders as text in the document, but rather just as a graphical cue for where you'll bounce when tabbing to the next placeholder in the edit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are, in fact, inserted literally into the buffer. This is required for Scintilla markers. Since we don't currently filter the document upon save, they are also saved to the file.
What do other editors insert when you save a file containing the placeholder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess yeah ideally the placeholder wouldn't be any actual character but simply a display thing, but I'm not sure Scintilla allows for this, does it? It would need be able to have an indicator that takes more room than the range it's on, which doesn't sounds likely, but I might miss an existing feature.
Otherwise for what the placeholder is I don't care that much; I just didn't feel like _
looked straightforward to me when using the thing, but I don't have a string opinion either. I still feel like 957b49b#commitcomment-23346900, but if the consensus is to keep _
I won't argue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess yeah ideally the placeholder wouldn't be any actual character but simply a display thing, but I'm not sure Scintilla allows for this, does it?
Since the placeholders are marked with a (presumably) unique indicator, there's no reason they couldn't be removed from the saved contents (mere matter of programming).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do other editors insert when you save a file containing the placeholder?
IIRC XCode and QtCreator enter some kind of special placeholder-filling mode where you can tab between them and fill them out, and then you commit them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't agree let's post-pone this very change. The rest of the PR is good and should be merged.
I still don't really like b998236 but otherwise looks good. |
If the placeholder is a string that will get saved it has to be something that will save in all encodings since the user can select that at save time, hence @kugel- used ASCII. But actually adding ANY characters to the buffer may result in illegal syntax. It would be better if the placeholder was not inserted at all. What about using the |
IMO just marking the position is too narrow. In fact, inserting no character is even more likely to produce invalid syntax. Think of empty for-loop specification or empty rhs of an assignment. Actually _ is probably least problematic because in many languages it's the only valid non-alphanumeric character in an identifier. I also like b4n's idea, but it's more work and should be a separate PR. |
@kugel- yeah, the little zit below the line is pretty easy to miss. Maybe underscore with an indicator in the INDIC_BOX family would be visible with minimal (but not zero) likelyhood of upsetting encodings and syntax and still being visible. Or let the snippet define the characters and display them with the indicator so the snippet has As I don't use snippets I am only concerned that we don't get complaints about encoding errors by using non-ASCII characters, the rest is just trying to be helpful, whatever you prefer is ok by me. |
While most encodings are roughly US-ASCII compatible, you'd have to survey every single supported encoding to ensure that character 95 is used for underscore and not something else. Some encodings are known to replace various US-ASCII characters with currency symbols, for example. |
So long as the character exists in the encoding there won't be any problems, but if the character does not exist in the target encoding then the file won't save. Doesn't matter if it encodes to something different, but if it does not exist Having symbol parsing temporarily incorrect is common while writing code, so incorrect syntax is probably less of a problem than being unable to save the file. Certainly ASCII alphabetics are the most likely to exist, and simple punctuation like dot (.). So maybe stick with the three character string "..." even if it will not be legal syntax in most languages. |
I'd say _ is equally likely to exist, and would prefer not to change it. |
Seems like for programming languages, being illegal would be an advantage. If something is inserting text I neither typed directly nor into the snippet, into my document, I'd at least like a compiler warning to track it down, rather than potentially compiling and doing something weird at runtime. |
I'm more concerned about the sidebar becoming busted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's back out b998236 and merge the rest, until we agree on a placeholder.
@@ -2394,7 +2394,7 @@ typedef struct | |||
} SelectionRange; | |||
|
|||
|
|||
#define CURSOR_PLACEHOLDER "_" /* Would rather use … but not all docs are unicode */ | |||
#define CURSOR_PLACEHOLDER "..." /* Would rather use … but not all docs are unicode */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't agree let's post-pone this very change. The rest of the PR is good and should be merged.
These were introduced in geany#1470 and a fix was also provided in geany#1554.
It makes more semantic sense than underscore, and is still full ASCII unlike the proper Unicode ellipsis.
Now the keybinding can be overridden (e.g. using Tab for it as well as normal behavior), beeping when there is no next cursor is more annoying than useful.
e7cd97f
to
2128bf1
Compare
Now the keybinding can be overridden (e.g. using Tab for it as well as normal behavior), beeping when there is no next cursor is more annoying than useful. Part of #1554.
I re-pushed after fixing the conflicts now @codebrainz committed 36f4474 (which is basically exactly the commit I had). I also cherry-picked 2128bf1 into master, so the only thing left is the controversial placeholder change. Closing for now. |
Followups on #1470.