Skip to content

Commit 0a1b901

Browse files
committed
Remove cursor position saving
1 parent 697cefd commit 0a1b901

File tree

2 files changed

+1
-24
lines changed

2 files changed

+1
-24
lines changed

js/edit.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/* global code_snippets_editor_atts */
22

33
window.code_snippets_editor = (function (CodeMirror, editor_atts) {
4-
const snippet_form = document.getElementById('snippet-form');
5-
64
const save_snippet_cb = (cm) => document.getElementById('save_snippet').click();
75

86
editor_atts['extraKeys'] = window.navigator.platform.match('Mac') ?
@@ -13,21 +11,6 @@ window.code_snippets_editor = (function (CodeMirror, editor_atts) {
1311
document.querySelector('.editor-help-text').className += ' platform-mac';
1412
}
1513

16-
const editor = CodeMirror.fromTextArea(document.getElementById('snippet_code'), editor_atts);
17-
18-
// set the cursor to the previous position
19-
let matches = window.location.href.match(/[?&]cursor_line=(\d+)&cursor_ch=(\d+)/);
20-
if (matches) {
21-
editor.focus();
22-
editor.setCursor({line: matches[1], ch: matches[2]});
23-
}
24-
25-
// send the current cursor position to the next page
26-
snippet_form.addEventListener('submit', () => {
27-
const cursor = editor.getCursor();
28-
snippet_form.insertAdjacentHTML('beforeend', `<input type="hidden" name="snippet_editor_cursor_line" value="${cursor.line}">`);
29-
snippet_form.insertAdjacentHTML('beforeend', `<input type="hidden" name="snippet_editor_cursor_ch" value="${cursor.ch}">`);
30-
});
14+
return CodeMirror.fromTextArea(document.getElementById('snippet_code'), editor_atts);
3115

32-
return editor;
3316
})(window.Code_Snippets_CodeMirror, code_snippets_editor_atts);

php/admin-menus/class-edit-menu.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,6 @@ private function save_posted_snippet() {
288288
code_snippets()->get_menu_url( 'edit' )
289289
);
290290

291-
if ( isset( $_POST['snippet_editor_cursor_line'], $_POST['snippet_editor_cursor_ch'] ) &&
292-
is_numeric( $_POST['snippet_editor_cursor_line'] ) && is_numeric( $_POST['snippet_editor_cursor_ch'] ) ) {
293-
$redirect_uri = add_query_arg( 'cursor_line', intval( $_POST['snippet_editor_cursor_line'] ), $redirect_uri );
294-
$redirect_uri = add_query_arg( 'cursor_ch', intval( $_POST['snippet_editor_cursor_ch'] ), $redirect_uri );
295-
}
296-
297291
wp_redirect( esc_url_raw( $redirect_uri ) );
298292
exit;
299293
}

0 commit comments

Comments
 (0)