Silence gopls hints (#2195)
This commit is contained in:
1 parent
4dc3d37684
commit
4bfd3c8ac5
9 files changed
+26
-27
No files matched your search
@@ -511,7 +511,7 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *app) runCmdSync(cmd *exec.Cmd, pause_after bool) {
|
func (app *app) runCmdSync(cmd *exec.Cmd, pauseAfter bool) {
|
||||||
app.nav.previewChan <- ""
|
app.nav.previewChan <- ""
|
||||||
|
|
||||||
if err := app.ui.suspend(); err != nil {
|
if err := app.ui.suspend(); err != nil {
|
||||||
@@ -527,7 +527,7 @@ func (app *app) runCmdSync(cmd *exec.Cmd, pause_after bool) {
|
|||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
app.ui.echoerrf("running shell: %s", err)
|
app.ui.echoerrf("running shell: %s", err)
|
||||||
}
|
}
|
||||||
if pause_after {
|
if pauseAfter {
|
||||||
anyKey()
|
anyKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ func (sm styleMap) parseFile(path string) {
|
|||||||
|
|
||||||
// This function parses $LS_COLORS environment variable.
|
// This function parses $LS_COLORS environment variable.
|
||||||
func (sm *styleMap) parseGNU(env string) {
|
func (sm *styleMap) parseGNU(env string) {
|
||||||
for _, entry := range strings.Split(env, ":") {
|
for entry := range strings.SplitSeq(env, ":") {
|
||||||
if entry == "" {
|
if entry == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -312,7 +312,7 @@ func matchShellFile(s string) (matches []compMatch, result string) {
|
|||||||
|
|
||||||
func matchExec(s string) (matches []compMatch, result string) {
|
func matchExec(s string) (matches []compMatch, result string) {
|
||||||
var words []string
|
var words []string
|
||||||
for _, p := range strings.Split(envPath, string(filepath.ListSeparator)) {
|
for p := range strings.SplitSeq(envPath, string(filepath.ListSeparator)) {
|
||||||
files, err := os.ReadDir(p)
|
files, err := os.ReadDir(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
|
|||||||
@@ -61,11 +61,11 @@ func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan in
|
|||||||
}
|
}
|
||||||
defer r.Close()
|
defer r.Close()
|
||||||
|
|
||||||
var dst_mode os.FileMode = 0o666
|
var dstMode os.FileMode = 0o666
|
||||||
if slices.Contains(preserve, "mode") {
|
if slices.Contains(preserve, "mode") {
|
||||||
dst_mode = info.Mode()
|
dstMode = info.Mode()
|
||||||
}
|
}
|
||||||
w, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, dst_mode)
|
w, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, dstMode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -132,11 +132,11 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
|||||||
newPath := filepath.Join(dst, rel)
|
newPath := filepath.Join(dst, rel)
|
||||||
switch {
|
switch {
|
||||||
case info.IsDir():
|
case info.IsDir():
|
||||||
var dst_mode = os.ModePerm
|
dstMode := os.ModePerm
|
||||||
if slices.Contains(preserve, "mode") {
|
if slices.Contains(preserve, "mode") {
|
||||||
dst_mode = info.Mode()
|
dstMode = info.Mode()
|
||||||
}
|
}
|
||||||
if err := os.MkdirAll(newPath, dst_mode); err != nil {
|
if err := os.MkdirAll(newPath, dstMode); err != nil {
|
||||||
errs <- fmt.Errorf("mkdir: %s", err)
|
errs <- fmt.Errorf("mkdir: %s", err)
|
||||||
}
|
}
|
||||||
if slices.Contains(preserve, "timestamps") {
|
if slices.Contains(preserve, "timestamps") {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ func (im *iconMap) parseFile(path string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (im *iconMap) parseEnv(env string) {
|
func (im *iconMap) parseEnv(env string) {
|
||||||
for _, entry := range strings.Split(env, ":") {
|
for entry := range strings.SplitSeq(env, ":") {
|
||||||
if entry == "" {
|
if entry == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ func splitWord(s string) (word, rest string) {
|
|||||||
// or double quotes can be used to escape whitespaces. Hash characters can be
|
// or double quotes can be used to escape whitespaces. Hash characters can be
|
||||||
// used to add a comment until the end of line. Leading and trailing space is
|
// used to add a comment until the end of line. Leading and trailing space is
|
||||||
// trimmed. Empty lines are skipped.
|
// trimmed. Empty lines are skipped.
|
||||||
func readArrays(r io.Reader, min_cols, max_cols int) ([][]string, error) {
|
func readArrays(r io.Reader, minCols, maxCols int) ([][]string, error) {
|
||||||
var arrays [][]string
|
var arrays [][]string
|
||||||
s := bufio.NewScanner(r)
|
s := bufio.NewScanner(r)
|
||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
@@ -209,11 +209,11 @@ func readArrays(r io.Reader, min_cols, max_cols int) ([][]string, error) {
|
|||||||
})
|
})
|
||||||
arrlen := len(arr)
|
arrlen := len(arr)
|
||||||
|
|
||||||
if arrlen < min_cols || arrlen > max_cols {
|
if arrlen < minCols || arrlen > maxCols {
|
||||||
if min_cols == max_cols {
|
if minCols == maxCols {
|
||||||
return nil, fmt.Errorf("expected %d columns but found: %s", min_cols, s.Text())
|
return nil, fmt.Errorf("expected %d columns but found: %s", minCols, s.Text())
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("expected %d~%d columns but found: %s", min_cols, max_cols, s.Text())
|
return nil, fmt.Errorf("expected %d~%d columns but found: %s", minCols, maxCols, s.Text())
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range arrlen {
|
for i := range arrlen {
|
||||||
|
|||||||
+5
-5
@@ -231,10 +231,10 @@ func TestSplitWord(t *testing.T) {
|
|||||||
|
|
||||||
func TestReadArrays(t *testing.T) {
|
func TestReadArrays(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
s string
|
s string
|
||||||
min_cols int
|
minCols int
|
||||||
max_cols int
|
maxCols int
|
||||||
exp [][]string
|
exp [][]string
|
||||||
}{
|
}{
|
||||||
{"foo bar", 2, 2, [][]string{{"foo", "bar"}}},
|
{"foo bar", 2, 2, [][]string{{"foo", "bar"}}},
|
||||||
{"foo bar ", 2, 2, [][]string{{"foo", "bar"}}},
|
{"foo bar ", 2, 2, [][]string{{"foo", "bar"}}},
|
||||||
@@ -249,7 +249,7 @@ func TestReadArrays(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
if got, _ := readArrays(strings.NewReader(test.s), test.min_cols, test.max_cols); !reflect.DeepEqual(got, test.exp) {
|
if got, _ := readArrays(strings.NewReader(test.s), test.minCols, test.maxCols); !reflect.DeepEqual(got, test.exp) {
|
||||||
t.Errorf("at input '%v' expected '%v' but got '%v'", test.s, test.exp, got)
|
t.Errorf("at input '%v' expected '%v' but got '%v'", test.s, test.exp, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -174,8 +174,7 @@ func setDefaults() {
|
|||||||
func setUserUmask() {}
|
func setUserUmask() {}
|
||||||
|
|
||||||
func isExecutable(f os.FileInfo) bool {
|
func isExecutable(f os.FileInfo) bool {
|
||||||
exts := strings.Split(envPathExt, string(filepath.ListSeparator))
|
for e := range strings.SplitSeq(envPathExt, string(filepath.ListSeparator)) {
|
||||||
for _, e := range exts {
|
|
||||||
if strings.HasSuffix(strings.ToLower(f.Name()), strings.ToLower(e)) {
|
if strings.HasSuffix(strings.ToLower(f.Name()), strings.ToLower(e)) {
|
||||||
log.Print(f.Name(), e)
|
log.Print(f.Name(), e)
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -797,8 +797,8 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
|||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
pwd := dir.path
|
pwd := dir.path
|
||||||
|
|
||||||
if strings.HasPrefix(pwd, gUser.HomeDir) {
|
if after, ok := strings.CutPrefix(pwd, gUser.HomeDir); ok {
|
||||||
pwd = filepath.Join("~", strings.TrimPrefix(pwd, gUser.HomeDir))
|
pwd = filepath.Join("~", after)
|
||||||
}
|
}
|
||||||
|
|
||||||
sep := string(filepath.Separator)
|
sep := string(filepath.Separator)
|
||||||
@@ -905,7 +905,7 @@ func (ui *ui) drawStat(nav *nav) {
|
|||||||
replace("%l", curr.linkTarget)
|
replace("%l", curr.linkTarget)
|
||||||
|
|
||||||
var fileInfo strings.Builder
|
var fileInfo strings.Builder
|
||||||
for _, section := range strings.Split(statfmt, "\x1f") {
|
for section := range strings.SplitSeq(statfmt, "\x1f") {
|
||||||
if !strings.Contains(section, "\x00") {
|
if !strings.Contains(section, "\x00") {
|
||||||
fileInfo.WriteString(section)
|
fileInfo.WriteString(section)
|
||||||
}
|
}
|
||||||
@@ -1008,7 +1008,7 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
var ruler strings.Builder
|
var ruler strings.Builder
|
||||||
for _, section := range strings.Split(rulerfmt, "\x1f") {
|
for section := range strings.SplitSeq(rulerfmt, "\x1f") {
|
||||||
if !strings.Contains(section, "\x00") {
|
if !strings.Contains(section, "\x00") {
|
||||||
ruler.WriteString(section)
|
ruler.WriteString(section)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user