Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs-master/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ gui:
# need to pass it separately in the pager command.
tabWidth: 4

# If true, show visual indicators for spaces (middle dot) and tabs (right arrow)
# in diff and staging views.
# This can be toggled from within Lazygit with the 'toggleShowWhitespace'
# keybinding (default `<c-v>`), but that will not change the default.
showWhitespace: false

# If true, capture mouse events.
# When mouse events are captured, it's a little harder to select text: e.g.
# requiring you to hold the option key when on macOS.
Expand Down Expand Up @@ -689,6 +695,7 @@ keybinding:
submitEditorText: <enter>
extrasMenu: '@'
toggleWhitespaceInDiffView: <ctrl+w>
toggleShowWhitespace: <ctrl+v>
increaseContextInDiffView: '}'
decreaseContextInDiffView: '{'
increaseRenameSimilarityThreshold: )
Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` q `` | Quit | |
| `` <ctrl+z> `` | Suspend the application | |
| `` <ctrl+w> `` | Toggle whitespace | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
| `` <ctrl+v> `` | Toggle show whitespace characters | Toggle whether spaces and tabs are rendered with visible markers (· for space, → for tab).<br><br>The default can be changed in the config file with the key 'gui.showWhitespace'. |
| `` z `` | Undo | The reflog will be used to determine what git command to run to undo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |
| `` Z `` | Redo | The reflog will be used to determine what git command to run to redo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |

Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` q `` | 終了 | |
| `` <ctrl+z> `` | Suspend the application | |
| `` <ctrl+w> `` | 空白表示の切り替え | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
| `` <ctrl+v> `` | Toggle show whitespace characters | Toggle whether spaces and tabs are rendered with visible markers (· for space, → for tab).<br><br>The default can be changed in the config file with the key 'gui.showWhitespace'. |
| `` z `` | 元に戻す | 最後のgitコマンドを元に戻すために実行するgitコマンドを決定するためにreflogが使用されます。これにはワーキングツリーへの変更は含まれません。コミットのみが考慮されます。 |
| `` Z `` | やり直す | 最後のgitコマンドをやり直すために実行するgitコマンドを決定するためにreflogが使用されます。これにはワーキングツリーへの変更は含まれません。コミットのみが考慮されます。 |

Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` q `` | 종료 | |
| `` <ctrl+z> `` | Suspend the application | |
| `` <ctrl+w> `` | 공백문자를 Diff 뷰에서 표시 여부 전환 | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
| `` <ctrl+v> `` | Toggle show whitespace characters | Toggle whether spaces and tabs are rendered with visible markers (· for space, → for tab).<br><br>The default can be changed in the config file with the key 'gui.showWhitespace'. |
| `` z `` | 되돌리기 (reflog) (실험적) | The reflog will be used to determine what git command to run to undo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |
| `` Z `` | 다시 실행 (reflog) (실험적) | The reflog will be used to determine what git command to run to redo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |

Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` q `` | Quit | |
| `` <ctrl+z> `` | Suspend the application | |
| `` <ctrl+w> `` | Toggle whitespace | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
| `` <ctrl+v> `` | Toggle show whitespace characters | Toggle whether spaces and tabs are rendered with visible markers (· for space, → for tab).<br><br>The default can be changed in the config file with the key 'gui.showWhitespace'. |
| `` z `` | Ongedaan maken (via reflog) (experimenteel) | The reflog will be used to determine what git command to run to undo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |
| `` Z `` | Redo (via reflog) (experimenteel) | The reflog will be used to determine what git command to run to redo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |

Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` q `` | Wyjdź | |
| `` <ctrl+z> `` | Suspend the application | |
| `` <ctrl+w> `` | Przełącz białe znaki | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
| `` <ctrl+v> `` | Toggle show whitespace characters | Toggle whether spaces and tabs are rendered with visible markers (· for space, → for tab).<br><br>The default can be changed in the config file with the key 'gui.showWhitespace'. |
| `` z `` | Cofnij | Dziennik reflog zostanie użyty do określenia, jakie polecenie git należy uruchomić, aby cofnąć ostatnie polecenie git. Nie obejmuje to zmian w drzewie roboczym; brane są pod uwagę tylko commity. |
| `` Z `` | Ponów | Dziennik reflog zostanie użyty do określenia, jakie polecenie git należy uruchomić, aby ponowić ostatnie polecenie git. Nie obejmuje to zmian w drzewie roboczym; brane są pod uwagę tylko commity. |

Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` q `` | Sair | |
| `` <ctrl+z> `` | Suspender a aplicação | |
| `` <ctrl+w> `` | Toggle whitespace | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
| `` <ctrl+v> `` | Toggle show whitespace characters | Toggle whether spaces and tabs are rendered with visible markers (· for space, → for tab).<br><br>The default can be changed in the config file with the key 'gui.showWhitespace'. |
| `` z `` | Desfazer | O reflog será usado para determinar qual comando git para executar para desfazer o último comando git. Isto não inclui mudanças na árvore de trabalho; apenas compromissos são tidos em consideração. |
| `` Z `` | Refazer | O reflog será usado para determinar qual comando git para executar para refazer o último comando git. Isto não inclui mudanças na árvore de trabalho; apenas compromissos são tidos em consideração. |

Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` q `` | Выйти | |
| `` <ctrl+z> `` | Suspend the application | |
| `` <ctrl+w> `` | Переключить отображение изменении пробелов в просмотрщике сравнении | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
| `` <ctrl+v> `` | Toggle show whitespace characters | Toggle whether spaces and tabs are rendered with visible markers (· for space, → for tab).<br><br>The default can be changed in the config file with the key 'gui.showWhitespace'. |
| `` z `` | Отменить (через reflog) (экспериментальный) | Журнал ссылок (reflog) будет использоваться для определения того, какую команду git запустить, чтобы отменить последнюю команду git. Сюда не входят изменения в рабочем дереве; учитываются только коммиты. |
| `` Z `` | Повторить (через reflog) (экспериментальный) | Журнал ссылок (reflog) будет использоваться для определения того, какую команду git нужно запустить, чтобы повторить последнюю команду git. Сюда не входят изменения в рабочем дереве; учитываются только коммиты. |

Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` q `` | 退出 | |
| `` <ctrl+z> `` | 挂起应用程序 | |
| `` <ctrl+w> `` | 切换是否在差异视图中显示空白字符差异 | 切换是否在差异视图中显示空白字符更改。<br><br>默认值可在配置文件中通过键 'git.ignoreWhitespaceInDiffView' 更改。 |
| `` <ctrl+v> `` | Toggle show whitespace characters | Toggle whether spaces and tabs are rendered with visible markers (· for space, → for tab).<br><br>The default can be changed in the config file with the key 'gui.showWhitespace'. |
| `` z `` | 撤销 | Reflog将用于确定运行哪个git命令来撤消最后一个git命令。这并不包括对工作树的更改,只考虑提交。 |
| `` Z `` | 重做 | Reflog将用于确定运行哪个git命令来重做上一个git命令。这并不包括对工作树的更改,只考虑提交。 |

Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` q `` | 結束 | |
| `` <ctrl+z> `` | Suspend the application | |
| `` <ctrl+w> `` | 切換是否在差異檢視中顯示空格變更 | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
| `` <ctrl+v> `` | Toggle show whitespace characters | Toggle whether spaces and tabs are rendered with visible markers (· for space, → for tab).<br><br>The default can be changed in the config file with the key 'gui.showWhitespace'. |
| `` z `` | 復原 | 將使用 reflog 確任 git 指令以復原。這不包括工作區更改;只考慮提交。 |
| `` Z `` | 取消復原 | 將使用 reflog 確任 git 指令以重作。這不包括工作區更改;只考慮提交。 |

Expand Down
7 changes: 7 additions & 0 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ gui:
# need to pass it separately in the pager command.
tabWidth: 4

# If true, show visual indicators for spaces (middle dot) and tabs (right arrow)
# in diff and staging views.
# This can be toggled from within Lazygit with the 'toggleShowWhitespace'
# keybinding (default `<c-v>`), but that will not change the default.
showWhitespace: false

# If true, capture mouse events.
# When mouse events are captured, it's a little harder to select text: e.g.
# requiring you to hold the option key when on macOS.
Expand Down Expand Up @@ -674,6 +680,7 @@ keybinding:
submitEditorText: <enter>
extrasMenu: '@'
toggleWhitespaceInDiffView: <c-w>
toggleShowWhitespace: <c-v>
increaseContextInDiffView: '}'
decreaseContextInDiffView: '{'
increaseRenameSimilarityThreshold: )
Expand Down
6 changes: 6 additions & 0 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ type GuiConfig struct {
// The number of spaces per tab; used for everything that's shown in the main view, but probably mostly relevant for diffs.
// Note that when using a pager, the pager has its own tab width setting, so you need to pass it separately in the pager command.
TabWidth int `yaml:"tabWidth" jsonschema:"minimum=1"`
// If true, show visual indicators for spaces (middle dot) and tabs (right arrow) in diff and staging views.
// This can be toggled from within Lazygit with the 'toggleShowWhitespace' keybinding (default `<c-v>`), but that will not change the default.
ShowWhitespace bool `yaml:"showWhitespace"`
// If true, capture mouse events.
// When mouse events are captured, it's a little harder to select text: e.g. requiring you to hold the option key when on macOS.
MouseEvents bool `yaml:"mouseEvents"`
Expand Down Expand Up @@ -498,6 +501,7 @@ type KeybindingUniversalConfig struct {
SubmitEditorText string `yaml:"submitEditorText"`
ExtrasMenu string `yaml:"extrasMenu"`
ToggleWhitespaceInDiffView string `yaml:"toggleWhitespaceInDiffView"`
ToggleShowWhitespace string `yaml:"toggleShowWhitespace"`
IncreaseContextInDiffView string `yaml:"increaseContextInDiffView"`
DecreaseContextInDiffView string `yaml:"decreaseContextInDiffView"`
IncreaseRenameSimilarityThreshold string `yaml:"increaseRenameSimilarityThreshold"`
Expand Down Expand Up @@ -783,6 +787,7 @@ func GetDefaultConfigForPlatform(platform string) *UserConfig {
ScrollOffMargin: 2,
ScrollOffBehavior: "margin",
TabWidth: 4,
ShowWhitespace: false,
MouseEvents: true,
SkipAmendWarning: false,
SkipDiscardChangeWarning: false,
Expand Down Expand Up @@ -981,6 +986,7 @@ func GetDefaultConfigForPlatform(platform string) *UserConfig {
SubmitEditorText: "<enter>",
ExtrasMenu: "@",
ToggleWhitespaceInDiffView: "<ctrl+w>",
ToggleShowWhitespace: "<ctrl+v>",
IncreaseContextInDiffView: "}",
DecreaseContextInDiffView: "{",
IncreaseRenameSimilarityThreshold: ")",
Expand Down
18 changes: 9 additions & 9 deletions pkg/gocui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -1556,28 +1556,28 @@ func lineWrap(line []cell, columns int) [][]cell {
// if currChr == 'g' {
// panic(n)
// }
isBreakPoint := func(s string) bool { return s == " " || s == "-" || s == "\u00B7" }

if n > columns {
// This code is convoluted but we've got comprehensive tests so feel free to do whatever you want
// to the code to simplify it so long as our tests still pass.
if currChr == " " {
// if the line ends in a space, we'll omit it. This means there'll be no
// way to distinguish between a clean break and a mid-word break, but
// I think it's worth it.
if currChr == " " || currChr == "\u00B7" {
// omit space or whitespace marker at line end
lines = append(lines, line[offset:i])
offset = i + 1
n = 0
} else if currChr == "-" {
// if the last character is hyphen and the width of line is equal to the columns
// retain hyphen at end of line
lines = append(lines, line[offset:i])
offset = i
n = rw
} else if lastWhitespaceIndex != -1 {
// if there is a space in the line and the line is not breaking at a space/hyphen
// if there is a space/hyphen/dot in the line and we're not breaking at one
if line[lastWhitespaceIndex].chr == "-" {
// if break occurs at hyphen, we'll retain the hyphen
// retain the hyphen at end of line
lines = append(lines, line[offset:lastWhitespaceIndex+1])
} else {
// if break occurs at space, we'll omit the space
// break at space or dot, omit it
lines = append(lines, line[offset:lastWhitespaceIndex])
}
// Either way, continue *after* the break
Expand All @@ -1593,7 +1593,7 @@ func lineWrap(line []cell, columns int) [][]cell {
n = rw
}
lastWhitespaceIndex = -1
} else if line[i].chr == " " || line[i].chr == "-" {
} else if isBreakPoint(line[i].chr) {
lastWhitespaceIndex = i
}
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/gui/context/merge_conflicts_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/jesseduffield/lazygit/pkg/gui/mergeconflicts"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/sasha-s/go-deadlock"
)

Expand Down Expand Up @@ -91,7 +92,11 @@ func (self *MergeConflictsContext) GetContentToRender() string {
}

func (self *MergeConflictsContext) setContent() {
self.GetView().SetContent(self.GetContentToRender())
content := self.GetContentToRender()
if self.c.UserConfig().Gui.ShowWhitespace {
content = utils.ShowWhitespaceCharacters(content, self.c.UserConfig().Gui.TabWidth)
}
self.GetView().SetContent(content)
}

func (self *MergeConflictsContext) FocusSelection() {
Expand Down
7 changes: 6 additions & 1 deletion pkg/gui/context/patch_explorer_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/patch_exploring"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
deadlock "github.com/sasha-s/go-deadlock"
)

Expand Down Expand Up @@ -90,7 +91,11 @@ func (self *PatchExplorerContext) Render() {
}

func (self *PatchExplorerContext) setContent() {
self.GetView().SetContent(self.GetContentToRender())
content := self.GetContentToRender()
if self.c.UserConfig().Gui.ShowWhitespace {
content = utils.ShowWhitespaceCharacters(content, self.c.UserConfig().Gui.TabWidth)
}
self.GetView().SetContent(content)
}

func (self *PatchExplorerContext) FocusSelection() {
Expand Down
10 changes: 10 additions & 0 deletions pkg/gui/controllers/global_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type
Description: self.c.Tr.ToggleWhitespaceInDiffView,
Tooltip: self.c.Tr.ToggleWhitespaceInDiffViewTooltip,
},
{
Key: opts.GetKey(opts.Config.Universal.ToggleShowWhitespace),
Handler: self.toggleShowWhitespace,
Description: self.c.Tr.ToggleShowWhitespace,
Tooltip: self.c.Tr.ToggleShowWhitespaceTooltip,
},
}
}

Expand Down Expand Up @@ -254,6 +260,10 @@ func (self *GlobalController) toggleWhitespace() error {
return (&ToggleWhitespaceAction{c: self.c}).Call()
}

func (self *GlobalController) toggleShowWhitespace() error {
return (&ToggleShowWhitespaceAction{c: self.c}).Call()
}

func (self *GlobalController) canShowRebaseOptions() *types.DisabledReason {
if self.c.Model().WorkingTreeStateAtLastCommitRefresh.None() {
return &types.DisabledReason{
Expand Down
6 changes: 6 additions & 0 deletions pkg/gui/controllers/helpers/patch_building_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/patch"
"github.com/jesseduffield/lazygit/pkg/gui/patch_exploring"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
)

type PatchBuildingHelper struct {
Expand Down Expand Up @@ -98,6 +99,11 @@ func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpt

mainContent := context.GetContentToRender()

if self.c.UserConfig().Gui.ShowWhitespace {
mainContent = utils.ShowWhitespaceCharacters(mainContent, self.c.UserConfig().Gui.TabWidth)
secondaryDiff = utils.ShowWhitespaceCharacters(secondaryDiff, self.c.UserConfig().Gui.TabWidth)
}

self.c.Contexts().CustomPatchBuilder.FocusSelection()

self.c.RenderToMainViews(types.RefreshMainOpts{
Expand Down
6 changes: 6 additions & 0 deletions pkg/gui/controllers/helpers/staging_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/patch_exploring"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
)

type StagingHelper struct {
Expand Down Expand Up @@ -101,6 +102,11 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) {
self.c.Contexts().Staging.FocusSelection()
}

if self.c.UserConfig().Gui.ShowWhitespace {
mainContent = utils.ShowWhitespaceCharacters(mainContent, self.c.UserConfig().Gui.TabWidth)
secondaryContent = utils.ShowWhitespaceCharacters(secondaryContent, self.c.UserConfig().Gui.TabWidth)
}

self.c.RenderToMainViews(types.RefreshMainOpts{
Pair: self.c.MainViewPairs().Staging,
Main: &types.ViewUpdateOpts{
Expand Down
4 changes: 4 additions & 0 deletions pkg/gui/controllers/local_commits_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ func secondaryPatchPanelUpdateOpts(c *ControllerCommon) *types.ViewUpdateOpts {
if c.Git().Patch.PatchBuilder.Active() {
patch := c.Git().Patch.PatchBuilder.RenderAggregatedPatch(false)

if c.UserConfig().Gui.ShowWhitespace {
patch = utils.ShowWhitespaceCharacters(patch, c.UserConfig().Gui.TabWidth)
}

return &types.ViewUpdateOpts{
Task: types.NewRenderStringWithoutScrollTask(patch),
Title: c.Tr.CustomPatch,
Expand Down
Loading