I use neovim-remote to open git diffs from inside Neovim's terminal. Outside of it, I simply use Neovim directly, since it's faster. I do that by configuring the env variable GIT_PAGER. Here is how they're configured in a ZSH session depending on whether I'm inside Neovim's terminal:
if [[ -z "${NVIM_LISTEN_ADDRESS}" ]]; then
export GIT_PAGER="nvim +'Man! | setfiletype git'"
else
export GIT_PAGER="nvr -cc tabnew --remote-wait +'Man! | setlocal bufhidden=wipe | setfiletype git' -"
fi
The issue
When opening the diff directly with Neovim, it is properly highlighted. On the other hand, when opening with neovim-remote, the hunks are not highlighted. Here are both files and their diff:
Correct diff
```
commit a674c60947349f03d1f56a803c9a3c95d437ec07 (HEAD -> gbrlsnchs-put-debug-logging-api, origin/eduardocfalcao-debug-logging-api-get-endpoint)
Author: Luis Eduardo Falcao
Date: Thu Jul 15 21:08:24 2021 -0300
Fixing debug flags list endpoint.
diff --git a/src/connect/api/debuglog/list.go b/src/connect/api/debuglog/list.go
index ea0ad69a12..8a3508fd02 100644
--- a/src/connect/api/debuglog/list.go
+++ b/src/connect/api/debuglog/list.go
@@ -51,7 +51,7 @@ func (e *listDebugFlagsEndpoint) Handle() api.ApiResult {
func getDebugFlags() []debugFlagDTO {
regions := debug.GetRegions()
- list := make([]debugFlagDTO, len(regions))
+ var list []debugFlagDTO
for _, region := range regions {
list = append(list, debugFlagDTO{
diff --git a/src/connect/api/debuglog/list_test.go b/src/connect/api/debuglog/list_test.go
index c68ff88bcd..4ad6be8aab 100644
--- a/src/connect/api/debuglog/list_test.go
+++ b/src/connect/api/debuglog/list_test.go
@@ -78,13 +78,14 @@ func (s *ListEndpointSuite) TestHandle(c *check.C) {
apiResult := endpoint.Handle()
- c.Check(apiResult.Response, check.Equals, http.StatusOK)
- c.Check(apiResult.Err, check.IsNil)
-
apiContentResult := apiResult.Json.([]debugFlagDTO)
debugFlagMap := debugFlagListToMap(apiContentResult)
-
regionNames := debug.GetRegionNames()
+
+ c.Check(apiResult.Response, check.Equals, http.StatusOK)
+ c.Check(apiResult.Err, check.IsNil)
+ c.Check(len(apiContentResult), check.Equals, len(regionNames))
+
for _, regionName := range regionNames {
if enabled, ok := debugFlagMap[regionName]; ok {
c.Check(enabled, check.Equals, debug.Enabled(debug.GetRegion(regionName)))
```
Ill-generated diff
```
commit a674c60947349f03d1f56a803c9a3c95d437ec07 (HEAD -> gbrlsnchs-put-debug-logging-api, origin/eduardocfalcao-debug-logging-api-get-endpoint)
Author: Luis Eduardo Falcao
Date: Thu Jul 15 21:08:24 2021 -0300
Fixing debug flags list endpoint.
diff --git a/src/connect/api/debuglog/list.go b/src/connect/api/debuglog/list.go
index ea0ad69a12..8a3508fd02 100644
--- a/src/connect/api/debuglog/list.go
+++ b/src/connect/api/debuglog/list.go
@@ -51,7 +51,7 @@ func (e *listDebugFlagsEndpoint) Handle() api.ApiResult {
func getDebugFlags() []debugFlagDTO {
regions := debug.GetRegions()
- list := make([]debugFlagDTO, len(regions))
+ var list []debugFlagDTO
for _, region := range regions {
list = append(list, debugFlagDTO{
diff --git a/src/connect/api/debuglog/list_test.go b/src/connect/api/debuglog/list_test.go
index c68ff88bcd..4ad6be8aab 100644
--- a/src/connect/api/debuglog/list_test.go
+++ b/src/connect/api/debuglog/list_test.go
@@ -78,13 +78,14 @@ func (s *ListEndpointSuite) TestHandle(c *check.C) {
apiResult := endpoint.Handle()
- c.Check(apiResult.Response, check.Equals, http.StatusOK)
- c.Check(apiResult.Err, check.IsNil)
-
apiContentResult := apiResult.Json.([]debugFlagDTO)
debugFlagMap := debugFlagListToMap(apiContentResult)
-
regionNames := debug.GetRegionNames()
+
+ c.Check(apiResult.Response, check.Equals, http.StatusOK)
+ c.Check(apiResult.Err, check.IsNil)
+ c.Check(len(apiContentResult), check.Equals, len(regionNames))
+
for _, regionName := range regionNames {
if enabled, ok := debugFlagMap[regionName]; ok {
c.Check(enabled, check.Equals, debug.Enabled(debug.GetRegion(regionName)))
```
That said, the issue seems to be in lines where there's only a whitespace. neovim-remote manages to trim them somehow, messing with the highlighting (the whitespaces are needed in order to highlight hunks properly).
A little context before the real issue:
I use neovim-remote to open git diffs from inside Neovim's terminal. Outside of it, I simply use Neovim directly, since it's faster. I do that by configuring the env variable
GIT_PAGER
. Here is how they're configured in a ZSH session depending on whether I'm inside Neovim's terminal:The issue
When opening the diff directly with Neovim, it is properly highlighted. On the other hand, when opening with neovim-remote, the hunks are not highlighted. Here are both files and their diff:
Correct diff
``` commit a674c60947349f03d1f56a803c9a3c95d437ec07 (HEAD -> gbrlsnchs-put-debug-logging-api, origin/eduardocfalcao-debug-logging-api-get-endpoint) Author: Luis Eduardo FalcaoIll-generated diff
``` commit a674c60947349f03d1f56a803c9a3c95d437ec07 (HEAD -> gbrlsnchs-put-debug-logging-api, origin/eduardocfalcao-debug-logging-api-get-endpoint) Author: Luis Eduardo FalcaoAnd here is the diff between both output diffs:
That said, the issue seems to be in lines where there's only a whitespace. neovim-remote manages to trim them somehow, messing with the highlighting (the whitespaces are needed in order to highlight hunks properly).