(moved out of #1136)
1. Open a C source file with the following text:
``` void foo(void) { printf("Hello world!\n"); }
void main() { foo(); } ```
2. On line 8, Ctrl+click on `foo`. Geany navigates to line 1, the definition of `foo`.
3. Insert the following text at the beginning of the document:
``` #include <stdio.h>
```
4. Invoke “Navigate back a location” (with the toolbar button or the keybinding).
Expected result: Geany navigates to line 10, which now contains the call to `foo` from which we jumped to the definition of `foo`.
Actual result: Geany navigates to line 8, because positions in the navqueue were not updated when extra text was inserted at the beginning of the document.
This is going to be somewhat tricky in some cases like replace all where changes are made to multiple places at once.
@elextr I’m [trying out](https://github.com/vfaronov/geany/commit/ff1f28d8295e785abea27033d48c1e40d06...) an approach based on Scintilla indicators. Instead of storing the actual position in the navqueue, I store a unique ID, and then fill that position with a special, hidden indicator with [its value set](http://www.scintilla.org/ScintillaDoc.html#SCI_SETINDICATORVALUE) to the same ID. To go to another queue item, I iterate over all ranges of this indicator in the document, until I get the range with the necessary ID.
So, in cases like replace-all, Scintilla does all the work for me.
I don’t even think this is too much of a hack. That indicator could reasonably be shown with [`INDIC_POINT`](http://www.scintilla.org/ScintillaDoc.html#SCI_INDICSETSTYLE) style, it would look like a trail of breadcrumbs.
I will probably need to limit the navqueue to some reasonable maximum length, so I don’t accumulate too many ranges that must be walked every time.
Also, I lose navqueue items whenever the document is reloaded.
github-comments@lists.geany.org