1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-02 08:57:19 -04:00

[fragment] Do not move to the top, when nonexisting fragment is in current document. Refs #42

Behaviour similar to bigger browsers.
This commit is contained in:
Witold Filipczyk 2020-04-28 19:13:36 +02:00
parent 95466e73ed
commit 5c57cf6270
3 changed files with 23 additions and 1 deletions

View File

@ -23,6 +23,7 @@ struct document_view {
int last_x, last_y; /**< last pos of window */ int last_x, last_y; /**< last pos of window */
int depth; int depth;
int used; int used;
int prev_y;
}; };
#define get_old_current_link(doc_view) \ #define get_old_current_link(doc_view) \

View File

@ -248,7 +248,6 @@ draw_doc(struct session *ses, struct document_view *doc_view, int active)
if (ses->navigate_mode == NAVIGATE_LINKWISE) { if (ses->navigate_mode == NAVIGATE_LINKWISE) {
check_vs(doc_view); check_vs(doc_view);
} else { } else {
check_link_under_cursor(ses, doc_view); check_link_under_cursor(ses, doc_view);
} }
@ -261,6 +260,22 @@ draw_doc(struct session *ses, struct document_view *doc_view, int active)
doc_view->vs->y = vy; doc_view->vs->y = vy;
set_link(doc_view); set_link(doc_view);
} }
if (vy == -1) {
struct location *loc = cur_loc(ses);
if (loc) {
struct uri *cur_uri = loc->vs.uri;
if (list_has_prev(ses->history.history, loc)) {
struct uri *prev_uri = loc->prev->vs.uri;
if (compare_uri(cur_uri, prev_uri, URI_BASE)) {
doc_view->vs->y = doc_view->prev_y;
set_link(doc_view);
}
}
}
}
} }
vx = vs->x; vx = vs->x;
vy = vs->y; vy = vs->y;

View File

@ -969,6 +969,12 @@ goto_link(struct session *ses, struct document_view *doc_view, struct link *link
assert(link && doc_view && ses); assert(link && doc_view && ses);
if_assert_failed return NULL; if_assert_failed return NULL;
if (doc_view->vs) {
doc_view->prev_y = doc_view->vs->y;
} else {
doc_view->prev_y = 0;
}
if (link_is_form(link)) { if (link_is_form(link)) {
struct el_form_control *fc = link->data.form_control; struct el_form_control *fc = link->data.form_control;