Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put cursor at top of file, not bottom #258

Closed
jidanni opened this issue Mar 14, 2023 · 4 comments
Closed

Put cursor at top of file, not bottom #258

jidanni opened this issue Mar 14, 2023 · 4 comments

Comments

@jidanni
Copy link

jidanni commented Mar 14, 2023

One notices in the editor (emacs) the cursor is always placed at the bottom of the file.
This is in contrast with where we expect it: the top of the file.

@fregante
Copy link
Owner

fregante commented Mar 14, 2023

What browser and editor are you using? Please read the text included in the issue templates, it asks to specify this information.

Cursor position and text selection should be brought over from the field, so if the cursor is at the top in the browser, it should be at the top in the editor too (on connection). Does that happen?

The only issue I know is that the selection isn't updated after the first connection:

@jidanni
Copy link
Author

jidanni commented Mar 14, 2023

Chrome, emacs.

  1. We first click an edit link.
  2. Now we click your icon on the browser margin.
  3. Voila a buffer appears in emacs.

Well all through this process no cursor position has yet to be
established in the browser.

In the emacs buffer the cursor is at the end of the buffer. We want it
to be in the beginning of the buffer.

We try point-min in an emacs hook:

(if(/= 0 (user-uid))
    (progn
      (and (require 'atomic-chrome nil t)
	   (add-hook 'atomic-chrome-edit-mode-hook
		     (lambda ()
		       (setq-local fill-column 99999)
		       (goto-char (point-min))))
	   (atomic-chrome-start-server))))

Alas that didn't help.

OK, starting over, and first clicking somewhere in the browser's textbox
before clicking your icon... result: same problem.

Alas, the https://github.com/alpha22jp/atomic-chrome maintainer is not
too active.

@jidanni
Copy link
Author

jidanni commented Mar 14, 2023

Also checking interaction, the cursor also gets put at the bottom both
ways on various interactions.

There is a reference to point-max here...

(defun atomic-chrome-send-buffer-text ()
  "Send request to update text with current buffer content."
  (interactive)
  (let ((socket (atomic-chrome-get-websocket (current-buffer)))
        (text (buffer-substring-no-properties (point-min) (point-max))))
    (when (and socket text)
      (websocket-send-text
       socket
       (json-encode
        (if (eq (websocket-server-conn socket) atomic-chrome-server-ghost-text)
            (list (cons "text" text))
          (list '("type" . "updateText")
                (cons "payload" (list (cons "text" text))))))))))

@fregante
Copy link
Owner

Cursor position and text selection should be brought over from the field

This is confirmed to happen in VS Code, so if it doesn't happen in your editor, you can open an issue in its GhostText plugin repo.

The browser extension correctly sets the cursor position where the user leaves it, even carrying over the initial selection, if any

Screen.Recording.2.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants