[Github-comments] [geany/geany] Push current position to navqueue before navigating back (#1537)

Matthew Brush notifications at xxxxx
Sat Jul 15 02:05:37 UTC 2017


codebrainz commented on this pull request.



> @@ -192,6 +192,14 @@ static gboolean goto_file_pos(const gchar *file, gint pos)
 void navqueue_go_back(void)
 {
 	filepos *fprev;
+	GeanyDocument *doc = document_get_current();
+
+	/* If the navqueue is currently at some position A, but the actual cursor is at some other
+	 * place B, we should add B to the navqueue, so that (1) we go back to A, not to the next
+	 * item in the queue; and (2) we can later restore B by going forward.
+	 * (If A = B, add_new_position will ignore it.) */
+	if (doc->file_name)
+		add_new_position(doc->file_name, sci_get_current_position(doc->editor->sci));

What I meant was:

```c
g_assert(doc);
g_assert(doc->file_name);
add_new_position(doc->file_name, sci_get_current_position(doc->editor->sci));
```

Since neither `doc` nor `doc->file_name` should ever be `NULL` unless someone is introducing a programming bug.

-- 
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/1537#pullrequestreview-50179389
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20170714/bb99d7ad/attachment.html>


More information about the Github-comments mailing list