firenvim icon indicating copy to clipboard operation
firenvim copied to clipboard

Neovim window is small in Protonmail

Open Louis-dM opened this issue 3 years ago • 4 comments

tldr: neovim only displays a few rows in protonmail

Detailed explanation:

What I tried to do

  • Logged onto ProtonMail (https://mail.protonmail.com/u/0/inbox)
  • Clicked "New Message"
  • Navigated to the message field
  • Pressed my keyboard shortcut to open firenvim (I don't have it set to appear automatically)

Expected behaviour

Gmail (https://mail.google.com/mail/u/0/#inbox) demonstrates the expected behaviour:

  • Screenshot 1: the editor is in the corner, and neovim fills the editing space
  • Screenshot 2: here the editor is maximised, and again the full space is used

The same (expected) behaviour also happens on Reddit: whether using the small editing box or the larger editor, neovim fills the whole space.

What happened

  • The window is only four lines high (three lines visible for editing, one for the command bar)
  • This happens whether the editor is in maximised or in the corner
  • Screenshot 1: when the editor is in the corner
  • Screenshot 2: when the editor is maximised

Software

  • OS Version: Fedora 35 (Gnome 41.3)
  • Browser Version: Firefox 96.0
  • Browser Addon Version: 0.2.12
  • Neovim Plugin Version: Not 100% sure how to check this, but I'm using vim-plug and have run PlugUpdate, so I think I'm up-to-date. Still getting the same thing.

Possibly relevant lines of Neovim config (can provide full file if needed but it's mostly just remaps):

" HIDING BARS AT BOTTOM
set laststatus=0
set noruler

" PLUGINS
call plug#begin()
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
cal plug#end()

" FIRENVIM STUFF
let g:firenvim_config = { 
    \ 'globalSettings': {
        \ 'alt': 'all',
    \  },
    \ 'localSettings': {
        \ '.*': {
            \ 'cmdline': 'neovim',
            \ 'content': 'text',
            \ 'priority': 0,
            \ 'selector': 'textarea',
            \ 'takeover': 'never',
        \ },
    \ }
\ }

Firefox config

In Firefox's "Manage Extension Shortcuts" settings, I have set the shortcut for "Turn the currently focused element into a neovim iframe." to Ctrl+Q. No other shortcuts are set.

Other notes

It seems that the size of the editor changes depending on how many lines are in the email when firenvim is started:

  • If (while not in Neovim) I delete the entire message contents and then hit Ctrl+Q to activate firenvim, the neovim instance is only high enough to display one line of text at a time.
  • If I (again, before entering Neovim) hit enter a few times and then press Ctrl+Q, the editor is as large as the email is. The upper limit of how big the Neovim window ends up being is the size of the editing window (i.e., this upper limit is the "expected behaviour").

Louis-dM avatar Jan 18 '22 16:01 Louis-dM

Thank you for the very detailed report, I really appreciate it :).

Unfortunately, there is nothing Firenvim can do to fix this - the neovim window takes the size of the underlying text area element, and protonmail's "real" text area element doesn't cover all of the "visual" text area.

You can try to work around this by running :set lines=20, possibly from a BufEnter autocommand. It should work as long as you don't also set guifont at the same time.

glacambre avatar Jan 18 '22 18:01 glacambre

:(

Using BufEnter might work, but it seems that the "filename" of what's happening in the neovim window is e.g. _blank_DIV-id-squire_<timestamp>Z.txt (i.e. nothing to do with the URL of the webpage). Would it be possible to change this "filename" to include parts of the URL to allow users to have custom BufEnter autocommands for situations like this?

(I've not got much experience with BufEnter, so please correct me if this isn't the way to go about it)

Louis-dM avatar Jan 19 '22 12:01 Louis-dM

You can use the filename setting to change the name of the underlying file. It's quite odd that you're not seeing the url of the page in the default file name though - I would have expected it to be there. Its absence probably means that protonmail's text-area lives in an iframe that doesn't have a url (which would also explain the "_blank" path) and unfortunately there's nothing Firenvim can do about this (I'm quite surprised Firenvim works at all, to be honest :sweat_smile:).

glacambre avatar Jan 19 '22 12:01 glacambre

Damn, well if it can't detect the URL in that window then I'll just have to hope _blank_DIV-id-squire*.txt is uncommon enough to work for the autocommand. Thanks anyways!

Louis-dM avatar Jan 19 '22 16:01 Louis-dM