Steps to reproduce
Run this shell command:
vim -Nu NONE -S <(tee <<'EOF'
vim9script
&formatoptions = 'o'
&indentexpr = 'g:IndentExpr()'
def g:IndentExpr(): number
return 0
enddef
['aaa', 'bbb//']->setline(1)
normal! GO
EOF
)
The buffer contains these lines:
aaa
//
bbb//
Expected behavior
The buffer contains these lines:
aaa
bbb//
Version of Vim
8.2 Included patches: 1-3932
Environment
Operating system: Ubuntu 20.04.3 LTS
Terminal: xterm
Value of $TERM: xterm-256color
Shell: zsh 5.8
Additional Context
Regression introduced in 8.2.3787.
—
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()
The issue persists for the o command:
vim -Nu NORC --cmd 'filetype indent on' -S <(tee <<'EOF'
vim9script
edit /tmp/sh.sh
&formatoptions = 'o'
var lines =<< trim END
#!/bin/bash
git clone 'https://github.com/vim/vim/'
END
lines->setline(1)
normal! Go
EOF
)
The buffer contains these lines:
#!/bin/bash
git clone https://github.com/vim/vim/
//
There is no reason for the C comment leader (//) to be inserted below the git(1) command:
—
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()
The cause for this appears to be that the 'comments' option for shell script does contain "://".
If you have a line starting with "//" and use "o" then the comment leader is also copied.
I could add a condition for 'cindent' being set, but this is really a text formatting feature, not indenting.
—
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()
can you (@brammool or Dan) please notify me once there are changes, so I can adjust the comments setting for zsh accordingly?
—
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()
The cause for this appears to be that the 'comments' option for shell script does contain "://".
If you have a line starting with "//" and use "o" then the comment leader is also copied.
I could add a condition for 'cindent' being set, but this is really a text formatting feature, not indenting.
Google tells me that this code in golang should run the previously mentioned git(1) command:
package main
import (
"log"
"os/exec"
)
func main() {
cmd := exec.Command("git clone 'https://github.com/vim/vim/'")
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
}
If we press o on the cmd assignment, // is inserted at the start of the newly created line. Again, there is no reason to do that. // is inside a quoted url. And this time, it can't be fixed by removing // from 'comments', because // is a valid comment leader in golang.
—
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()
For finding "//" inside a string there is a todo item. Let's see if I can fix that...
—
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()