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

Wrong hat positions in dired mode b/c of hidden text #15

Open
rntz opened this issue Aug 31, 2022 · 3 comments
Open

Wrong hat positions in dired mode b/c of hidden text #15

rntz opened this issue Aug 31, 2022 · 3 comments

Comments

@rntz
Copy link
Collaborator

rntz commented Aug 31, 2022

I think this is because my dired-mode setup hides some text (the file modes, owner, mtime, etc), but it still shows up in the buffer contents and gets sent to cursorless, so the hat positions are messed up.

@dyamito
Copy link
Contributor

dyamito commented Sep 3, 2022

I think we need to be using buffer-substring-no-properties instead of write-region here:

(write-region nil nil (cursorless-temporary-file-path) nil 'ignore-message))
That way it will only write out the visible text. One downside is I think that would bring everything into RAM, which might be wasteful for bigger files, shells, etc.

@rntz
Copy link
Collaborator Author

rntz commented Sep 3, 2022

buffer-substring-no-properties doesn't do what we want either. eg. if I go to a dired buffer I see:

  /home/rntz/t/example:
  total used in directory 25 available 40.6 GiB
  * example.txt

but the actual text that is produced by either write-region or by buffer-substring-no-properties or by copying is:

   /home/rntz/t/example:
  total used in directory 25 available 40.6 GiB
  -rw-rw-r-- rntz rntz     5 09-03 23:24 example.txt

This is because of dired-details: it hides the modes, owner, group, mtime, etc; replacing them by *. It does this using an overlay which makes the hidden text invisible and inserts the string "* " before it.

Clearly we don't want to send the hidden text to VSCode. Oddly enough we also might not want to send the replacement text ("* ") to VSCode, because it's not editable and the cursor can't actually select it. Either way involves some annoying arithmetic to figure out how to sync hat/cursor positions b/w emacs & vscode.

@dyamito
Copy link
Contributor

dyamito commented Sep 5, 2022

Ugh, you're right. I ran into this same issue with magit, both are using the invisibility spec stuff - https://www.gnu.org/software/emacs/manual/html_node/elisp/Invisible-Text.html.

Oddly enough we also might not want to send the replacement text ("* ") to VSCode, because it's not editable and the cursor can't actually select it.

I think we can punt on this for a while, this is a whole can of worms that we're going to run into with shells too - e.g. allow editing the command line but not any of the output from previous commands.

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