Repository: jesseduffield/lazygit (language: go)

Issue:
Square Brackets in Commit Messages not allowed
I'm using a tag like system with Square Brackets in Commit Messages. Lazygit won't allow me to type Square or Curly Brackets. Regular Brackets work fine.
I already unset the Keybinds for the Square Brackets, but this didn't change the behavior.


Discussion / hints:
Please fill out the `Bug report` template, I can type in `[][][]` in my commit message.
Not sure why i didn't get the template on creating the issue so, here goes:

**Describe the bug**
When using "commit changes" i can not type Square or Curly Brackets. "commit changes using git editor" works fine.

**To Reproduce**
1. Install lazygit on Windows 11
2. Run lazygit in Terminal (new Windows terminal and old cmd tested)
3. Stage any change
4. Press "c" to commit
5. Try typing `[ ]` or `{ }`

**Expected behavior**
Brackets can be typed as expected

**Screenshots**
Not sure what to screenshot, since nothing is written into the Message Box

**Version info:**
commit=16802a048e0425182f08cf0e9a2bc31480e9a55d, build date=2023-02-01T11:02:43Z, build source=binaryRelease, version=0.37.0, os=windows, arch=amd64, git version=2.40.0.windows.1

git version 2.40.0.windows.1

**Debugging Results:**
Not a lot. When opening the commit window and typing, nothing is logged.
One Error seems to be that lazygit is trying to merge to master in the background, which doesn't work for this repository, as the branch is called main and we don't have a master branch. I doubt that it has anything to do with this issue though.
The Log:
```
Apr 25 14:28:30 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Apr 25 14:28:30 |DEBU| RunCommand command="C:\\Program Files\\Git\\cmd\\git.exe diff --submodule --no-ext-diff --unified=3 --color=always --cached -- environments/bfk_schulung/group_vars"
Apr 25 14:28:36 |DEBU| RunCommand command="C:\\Program Files\\Git\\cmd\\git.exe log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium refs/heads/main --"
Apr 25 14:28:38 |DEBU| RunCommand command="C:\\Program Files\\Git\\cmd\\git.exe diff --submodule --no-ext-diff --unified=3 --color=always --cached -- environments/bfk_schulung/group_vars"
Apr 25 14:28:38 |ERRO| Unexpected error when running cmd task: exit status 1
Apr 25 14:28:40 |DEBU| RunCommand command="C:\\Program Files\\Git\\cmd\\git.exe diff --submodule --no-ext-diff --unified=3 --color=always --cached -- environments/bfk_schulung/group_vars/all.yml"
Apr 25 14:28:40 |DEBU| using cache for key status.showUntrackedFiles
Apr 25 14:28:40 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Apr 25 14:28:40 |DEBU| RunCommand command="C:\\Program Files\\Git\\cmd\\git.exe diff --submodule --no-ext-diff --unified=3 --color=always --cached -- environments/bfk_schulung/group_vars/all.yml"
Apr 25 14:28:41 |DEBU| RunCommand command="C:\\Program Files\\Git\\cmd\\git.exe diff --submodule --no-ext-diff --unified=3 --color=always --cached -- environments/bfk_schulung/group_vars"
Apr 25 14:28:50 |DEBU| using cache for key status.showUntrackedFiles
Apr 25 14:28:50 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Apr 25 14:28:50 |DEBU| RunCommand command="C:\\Program Files\\Git\\cmd\\git.exe diff --submodule --no-ext-diff --unified=3 --color=always --cached -- environments/bfk_schulung/group_vars"
Apr 25 14:28:51 |DEBU| RunCommand command="git fetch"
Apr 25 14:28:53 |INFO| refreshing the following scopes in async mode: branches,commits,remotes,tags
Apr 25 14:28:53 |DEBU| RunCommand command="git branch -r"
Apr 25 14:28:53 |DEBU| RunCommand command="git tag --list --sort=-creatordate"
Apr 25 14:28:53 |DEBU| RunCommand command="git merge-base \\\"HEAD\\\" \\\"HEAD\\\"@{u}"
Apr 25 14:28:53 |DEBU| RunCommand command="git for-each-ref --sort=-committerdate --format=\"%(HEAD)%00%(refname:short)%00%(upstream:short)%00%(upstream:track)\" refs/heads"
Apr 25 14:28:53 |DEBU| RunCommand command="git symbolic-ref --short HEAD"
Apr 25 14:28:53 |DEBU| RunCommand command="git merge-base \\\"HEAD\\\" \\\"master\\\""
Apr 25 14:28:53 |ERRO| fatal: Not a valid object name master
 command="git merge-base \\\"HEAD\\\" \\\"master\\\""
Apr 25 14:29:00 |DEBU| using cache for key status.showUntrackedFiles
Apr 25 14:29:00 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Apr 25 14:29:00 |DEBU| RunCommand command="C:\\Program Files\\Git\\cmd\\git.exe diff --submodule --no-ext-diff --unified=3 --color=always --cached -- environments/bfk_schulung/group_vars"
Apr 25 14:29:10 |DEBU| using cache for key status.showUntrackedFiles
Apr 25 14:29:10 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Apr 25 14:29:20 |DEBU| using cache for key status.showUntrackedFiles
Apr 25 14:29:20 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Apr 25 14:29:27 |DEBU| RunCommand command="C:\\Program Files\\Git\\cmd\\git.exe diff --submodule --no-ext-diff --unified=3 --color=always --cached -- environments/bfk_schulung/group_vars"
```

Are you using a US keyboard layout or some other?
That's interesting.
I'm using the German Keyboard Layout. Switching my OS to English(US) i can type Brackets without issues.
Not sure if it's important, but typing those brackets requires pressing Right Alt (Alt-Gr) plus Numbers 7 to 0
That's what I was aiming at, the combination of `AltGr+key` is what causes it, I'm guessing.

Thanks for reporting, at least you have a workaround until it's properly fixed! :)
I have this issue too, and it's quite a dealbreaker since we prefix all our commit messages with stuff like [FIX]. In my case, it's a french keyboard, and to get a '[', I normally need to press AltGr + 5

In editors.go, handleEditorKeypress() enters the following code:

		// TODO: see if we need all three of these conditions: maybe the final one is sufficient
	case ch != 0 && mod == 0 && unicode.IsPrint(ch):
		textArea.TypeRune(ch)

ch == 91 (ASCII for '[' ) and mod == ModMotion|ModAlt.

Simply removing `&& mod == 0` fixes the issue.

(I can provide a PR if you prefer)
Happens to me as well, using the Spanish (International sort) keyboard layout. Cannot input square brackets despite working normally in other editors (Neovim) / programs
@Calvin1602 	I'm happy to accept a PR with your proposed change

Fix patch:
diff --git a/pkg/gui/editors.go b/pkg/gui/editors.go
index b095630ece3..fdbe67a39d1 100644
--- a/pkg/gui/editors.go
+++ b/pkg/gui/editors.go
@@ -47,8 +47,7 @@ func (gui *Gui) handleEditorKeypress(textArea *gocui.TextArea, key gocui.Key, ch
 	case key == gocui.KeyCtrlY:
 		textArea.Yank()
 
-		// TODO: see if we need all three of these conditions: maybe the final one is sufficient
-	case ch != 0 && mod == 0 && unicode.IsPrint(ch):
+	case unicode.IsPrint(ch):
 		textArea.TypeRune(ch)
 	default:
 		return false


Test patch: