[Github-comments] [geany/geany] Better snippets (#1470)

Vasiliy Faronov notifications at xxxxx
Sun Jun 25 14:12:47 UTC 2017


I have been running with this PR for some time. I’m not a heavy user of snippets, but I do use a few.

I also tested this PR specifically, under Linux GTK+2, Linux GTK+3, and Windows GTK+2. Things like:

* inserting various snippets, jumping around them;
* completing a snippet inside another snippet;
* completing a snippet inside a compiler error (to see how the two indicators interact);
* invoking editing operations (like deleting an entire line) while inside a snippet expansion.

--------------------------------------------------

**Bug:** when the cursor is on *or after* the last cursor position (ellipsis), pressing the “Move cursor in snippet” keybinding moves the cursor to the end of the document. In more detail:

1. Open a non-empty Python document.
2. Put the cursor somewhere, type `for`, and press the “Complete snippet” keybinding. The snippet expands, and the cursor jumps to inside the parentheses in `xrange(…)`.
3. Press the “Move cursor in snippet” keybinding.
4. On master, the cursor stays in place. But with this PR, the cursor jumps to the end of the document.

--------------------------------------------------

**Bug:** when the cursor is at the beginning of the document, and there’s an ellipsis right there, pressing the “Move cursor in snippet” keybinding skips that ellipsis and selects the following run of text instead. In more detail:

1. Define a snippet like this:

       [Default]
       test=%cursor% something

2. Open an empty document.
3. Type `test` and press the “Complete snippet” keybinding. The snippet expands to `… something`.
4. Press Home to move the cursor to the beginning.
5. Press the “Move cursor in snippet” keybinding. The `…` should be selected, but instead ` something` is selected.

--------------------------------------------------

Consider the main change this PR brings. Previously, cursor positions were invisible and transient. Now, they are marked with an ellipsis (as can be seen on [Thomas’s screenshot](https://cloud.githubusercontent.com/assets/564520/25215453/db96d138-259d-11e7-9469-33dff37993de.png)), which is *literally* inserted into the document. It looks nice, but might have unintended side effects.

Try this:

1. Open an empty (but existing) Python file.
2. Type `def` and press the “Complete snippet” keybinding. The document now contains:

       def … (…):
           """ Function doc """
           ‌

3. On Windows, this “function” actually appears in the sidebar’s Symbols pane, with a placeholder name that looks like ⛝, and at the same time, a warning is printed to the console:

       Pango: Invalid UTF-8 string passed to pango_layout_set_text()

4. On Linux, nothing appears in the Symbols pane, but another warning is printed:

       geany: Warning: ignoring null tag in /home/vasiliy/tmp/untitled.py

This may or may not be a problem. You could as well type funny Unicode stuff manually into the document...


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1470#issuecomment-310904950
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20170625/21d2f470/attachment.html>


More information about the Github-comments mailing list