Skip to content

Commit 5e9b04a

Browse files
revert: hide rprompt when the prompt is too large
This reverts commit a8d4e51.
1 parent a8d4e51 commit 5e9b04a

File tree

7 files changed

+5
-78
lines changed

7 files changed

+5
-78
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"request": "launch",
88
"mode": "debug",
99
"program": "${workspaceRoot}/src",
10-
"args": ["--config=${workspaceRoot}/themes/jandedobbeleer.omp.json", "--shell=pwsh"]
10+
"args": ["--config=${workspaceRoot}/themes/jandedobbeleer.omp.json"]
1111
},
1212
{
1313
"name": "Launch tests",

src/engine.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,6 @@ func (e *engine) string() string {
2525
return e.console.String()
2626
}
2727

28-
func (e *engine) canWriteRPrompt() bool {
29-
prompt := e.string()
30-
consoleWidth, err := e.env.getTerminalWidth()
31-
if err != nil {
32-
return true
33-
}
34-
promptWidth := e.ansi.lenWithoutANSI(prompt)
35-
availableSpace := consoleWidth - promptWidth
36-
if promptWidth > consoleWidth {
37-
availableSpace = promptWidth - (promptWidth % consoleWidth)
38-
}
39-
promptBreathingRoom := 30
40-
return (availableSpace - e.ansi.lenWithoutANSI(e.rprompt)) >= promptBreathingRoom
41-
}
42-
4328
func (e *engine) render() string {
4429
for _, block := range e.config.Blocks {
4530
e.renderBlock(block)
@@ -166,7 +151,7 @@ func (e *engine) print() string {
166151
prompt += fmt.Sprintf("\nRPROMPT=\"%s\"", e.rprompt)
167152
return prompt
168153
case pwsh, powershell5, bash, plain:
169-
if e.rprompt == "" || !e.canWriteRPrompt() {
154+
if e.rprompt == "" {
170155
break
171156
}
172157
e.write(e.ansi.saveCursorPosition)

src/engine_test.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/environment.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/distatus/battery"
1717
"github.com/shirou/gopsutil/host"
1818
"github.com/shirou/gopsutil/process"
19-
terminal "github.com/wayneashleyberry/terminal-dimensions"
2019
)
2120

2221
const (
@@ -74,7 +73,6 @@ type environmentInfo interface {
7473
hasParentFilePath(path string) (fileInfo *fileInfo, err error)
7574
isWsl() bool
7675
stackCount() int
77-
getTerminalWidth() (int, error)
7876
}
7977

8078
type commandCache struct {
@@ -325,11 +323,6 @@ func (env *environment) stackCount() int {
325323
return *env.args.StackCount
326324
}
327325

328-
func (env *environment) getTerminalWidth() (int, error) {
329-
width, err := terminal.Width()
330-
return int(width), err
331-
}
332-
333326
func cleanHostName(hostName string) string {
334327
garbage := []string{
335328
".lan",

src/go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ require (
2626
github.com/stretchr/objx v0.3.0 // indirect
2727
github.com/stretchr/testify v1.7.0
2828
github.com/tklauser/go-sysconf v0.3.5 // indirect
29-
github.com/wayneashleyberry/terminal-dimensions v1.0.0
30-
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
29+
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
3130
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
3231
golang.org/x/sys v0.0.0-20210324051608-47abb6519492
3332
golang.org/x/text v0.3.5

src/go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,12 @@ github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITn
101101
github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA=
102102
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
103103
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
104-
github.com/wayneashleyberry/terminal-dimensions v1.0.0 h1:LawtS1nqKjAfqrmKOzkcrDLAjSzh38lEhC401JPjQVA=
105-
github.com/wayneashleyberry/terminal-dimensions v1.0.0/go.mod h1:PW2XrtV6KmKOPhuf7wbtcmw1/IFnC39mryRET2XbxeE=
106104
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
107105
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
108106
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
109107
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
110-
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc=
111-
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
108+
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
109+
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
112110
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk=
113111
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
114112
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

src/segment_path_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ func (env *MockedEnvironment) isWsl() bool {
142142
return false
143143
}
144144

145-
func (env *MockedEnvironment) getTerminalWidth() (int, error) {
146-
args := env.Called(nil)
147-
return args.Int(0), args.Error(1)
148-
}
149-
150145
const (
151146
homeBill = "/home/bill"
152147
homeJan = "/usr/home/jan"

0 commit comments

Comments
 (0)