before_code
stringlengths
14
465k
reviewer_comment
stringlengths
16
64.5k
after_code
stringlengths
9
467k
diff_context
stringlengths
0
97k
file_path
stringlengths
5
226
comment_line
int32
0
26
language
stringclasses
37 values
quality_score
float32
0.07
1
comment_type
stringclasses
9 values
comment_length
int32
16
64.5k
before_lines
int32
1
17.2k
after_lines
int32
1
12.1k
is_negative
bool
2 classes
pr_title
stringlengths
1
308
pr_number
int32
1
299k
repo_name
stringclasses
533 values
repo_stars
int64
321
419k
repo_language
stringclasses
27 values
reviewer_username
stringlengths
0
39
author_username
stringlengths
2
39
} } // DisableReload disables future reloads of this sharedbuffer func (b *SharedBuffer) DisableReload() { b.ReloadDisabled = true } const ( DSUnchanged = 0 DSAdded = 1 DSModified = 2 DSDeletedAbove = 3 ) type DiffStatus byte type CommandOrder int const ( None CommandOrder = i...
How about making it a bit shorter: `BufCommand`? Or even just `Command`? Other packages will refer to it as `buffer.Command` anyway.
} // calcHash calculates md5 hash of all lines in the buffer func (b *SharedBuffer) calcHash(out *[md5.Size]byte) { h := md5.New() if len(b.lines) > 0 { h.Write(b.lines[0].data) for _, l := range b.lines[1:] { if b.Endings == FFDos { h.Write([]byte{'\r', '\n'}) } else { h.Write([]byte{'\n'}) }...
@@ -175,6 +175,26 @@ const ( type DiffStatus byte +type CommandOrder int + +const ( + None CommandOrder = iota + StartCursorSearchText CommandOrder = iota + SearchTextStartCursor CommandOrder = iota +) + +type BufferCommand struct {
internal/buffer/buffer.go
26
Go
0.5
question
135
51
51
false
micro: Handle +/text search text from args
3,767
zyedidia/micro
13,805
Go
dmaluka
luca020400
// a circular dependency between packages). OptionCallback func(option string, nativeValue interface{}) // The display module registers its own GetVisualX function for getting // the correct visual x location of a cursor when softwrap is used. // This is hacky. Maybe it would be better to move all the visual x lo...
The argument name doesn't need to be as verbose as `bufferCommand`?
StartCursor Loc SearchRegex string SearchAfterStart bool } var emptyCommand = Command{ StartCursor: Loc{-1, -1}, SearchRegex: "", SearchAfterStart: false, } // Buffer stores the main information about a currently open file including // the actual text (in a LineArray), the undo/redo stack (i...
@@ -217,19 +237,19 @@ type Buffer struct { OverwriteMode bool } -// NewBufferFromFileAtLoc opens a new buffer with a given cursor location -// If cursorLoc is {-1, -1} the location does not overwrite what the cursor location +// NewBufferFromFileWithCommand opens a new buffer with a given command +// If bufferComm...
internal/buffer/buffer.go
26
Go
0.357
question
67
51
51
false
micro: Handle +/text search text from args
3,767
zyedidia/micro
13,805
Go
dmaluka
luca020400
flagVersion = flag.Bool("version", false, "Show the version number and information") flagConfigDir = flag.String("config-dir", "", "Specify a custom location for the configuration directory") flagOptions = flag.Bool("options", false, "Show all option help") flagDebug = flag.Bool("debug", false, "Enable debu...
It is a regex, not just a text?
flagVersion = flag.Bool("version", false, "Show the version number and information") flagConfigDir = flag.String("config-dir", "", "Specify a custom location for the configuration directory") flagOptions = flag.Bool("options", false, "Show all option help") flagDebug = flag.Bool("debug", false, "Enable debu...
@@ -55,6 +55,8 @@ func InitFlags() { fmt.Println("[FILE]:LINE:COL (if the `parsecursor` option is enabled)") fmt.Println("+LINE:COL") fmt.Println(" \tSpecify a line and column to start the cursor at when opening a buffer") + fmt.Println("+/TEXT") + fmt.Println(" \tSpecify text to search for when openin...
cmd/micro/micro.go
26
Go
0.071
question
31
51
51
false
micro: Handle +/text search text from args
3,767
zyedidia/micro
13,805
Go
dmaluka
luca020400
flagStartPos = buffer.Loc{0, line - 1} posIndex = i } else { searchMatch := searchFlagr.FindStringSubmatch(a) if len(searchMatch) == 2 { searchText = searchMatch[1] searchIndex = i } else { files = append(files, a) } } } searchAfterStart := searchIndex != -1 // If both flags are s...
All the above could be replaced with just `SearchAfterStart: searchIndex > posIndex` here?
continue } flagStartPos = buffer.Loc{0, line - 1} posIndex = i } else { searchMatch := searchFlagr.FindStringSubmatch(a) if len(searchMatch) == 2 { searchText = searchMatch[1] searchIndex = i } else { files = append(files, a) } } } command := buffer.Command{ StartCursor: ...
@@ -165,39 +167,69 @@ func LoadInput(args []string) []*buffer.Buffer { } files := make([]string, 0, len(args)) + flagStartPos := buffer.Loc{-1, -1} - flagr := regexp.MustCompile(`^\+(\d+)(?::(\d+))?$`) - for _, a := range args { - match := flagr.FindStringSubmatch(a) - if len(match) == 3 && match[2] != "" { -...
cmd/micro/micro.go
26
Go
0.429
question
90
51
51
false
micro: Handle +/text search text from args
3,767
zyedidia/micro
13,805
Go
dmaluka
luca020400
screen.TermMessage(err) continue } flagStartPos = buffer.Loc{0, line - 1} posIndex = i } else { searchMatch := searchFlagr.FindStringSubmatch(a) if len(searchMatch) == 2 { searchText = searchMatch[1] searchIndex = i } else { files = append(files, a) } } } searchAfterStart...
nit: it can be just `command := ...`
line, err := strconv.Atoi(posMatch[1]) if err != nil { screen.TermMessage(err) continue } flagStartPos = buffer.Loc{0, line - 1} posIndex = i } else { searchMatch := searchFlagr.FindStringSubmatch(a) if len(searchMatch) == 2 { searchText = searchMatch[1] searchIndex = i } else ...
@@ -165,39 +167,69 @@ func LoadInput(args []string) []*buffer.Buffer { } files := make([]string, 0, len(args)) + flagStartPos := buffer.Loc{-1, -1} - flagr := regexp.MustCompile(`^\+(\d+)(?::(\d+))?$`) - for _, a := range args { - match := flagr.FindStringSubmatch(a) - if len(match) == 3 && match[2] != "" { -...
cmd/micro/micro.go
26
Go
0.214
nitpick
36
51
51
false
micro: Handle +/text search text from args
3,767
zyedidia/micro
13,805
Go
dmaluka
luca020400
} b.Highlighter.HighlightMatches(b, start, l) } for i := start; i <= end; i++ { b.LineArray.invalidateSearchMatches(i) } } // DisableReload disables future reloads of this sharedbuffer func (b *SharedBuffer) DisableReload() { b.ReloadDisabled = true } const ( DSUnchanged = 0 DSAdded = 1 DSModi...
Same here: e.g. `SearchRegex` might be better?
if b.isModified { b.RequestBackup() } else { b.CancelBackup() } } // calcHash calculates md5 hash of all lines in the buffer func (b *SharedBuffer) calcHash(out *[md5.Size]byte) { h := md5.New() if len(b.lines) > 0 { h.Write(b.lines[0].data) for _, l := range b.lines[1:] { if b.Endings == FFDos { ...
@@ -175,6 +175,18 @@ const ( type DiffStatus byte +type Command struct { + StartCursor Loc + SearchText string
internal/buffer/buffer.go
26
Go
0.286
question
46
51
51
false
micro: Handle +/text search text from args
3,767
zyedidia/micro
13,805
Go
dmaluka
luca020400
// a circular dependency between packages). OptionCallback func(option string, nativeValue interface{}) // The display module registers its own GetVisualX function for getting // the correct visual x location of a cursor when softwrap is used. // This is hacky. Maybe it would be better to move all the visual x lo...
Just a note: it could be even shorter: `cmd`. (I'm fine either way.)
DSAdded = 1 DSModified = 2 DSDeletedAbove = 3 ) type DiffStatus byte type Command struct { StartCursor Loc SearchRegex string SearchAfterStart bool } var emptyCommand = Command{ StartCursor: Loc{-1, -1}, SearchRegex: "", SearchAfterStart: false, } // Buffer stores the main in...
@@ -217,19 +229,19 @@ type Buffer struct { OverwriteMode bool } -// NewBufferFromFileAtLoc opens a new buffer with a given cursor location -// If cursorLoc is {-1, -1} the location does not overwrite what the cursor location +// NewBufferFromFileWithCommand opens a new buffer with a given command +// If command.cu...
internal/buffer/buffer.go
26
Go
0.429
suggestion
68
51
51
false
micro: Handle +/text search text from args
3,767
zyedidia/micro
13,805
Go
dmaluka
luca020400
} b.UpdateRules() // we know the filetype now, so update per-filetype settings config.UpdateFileTypeLocals(b.Settings, b.Settings["filetype"].(string)) if _, err := os.Stat(filepath.Join(config.ConfigDir, "buffers")); errors.Is(err, fs.ErrNotExist) { os.Mkdir(filepath.Join(config.ConfigDir, "buffers"), os.Mode...
We should search from `b.StartCursor`, not from `b.Start()`? (That is what vim does, for instance.)
if !ok { return NewBufferFromString("", "", btype) } if !hasBackup { reader := bufio.NewReader(transform.NewReader(r, b.encoding.NewDecoder())) var ff FileFormat = FFAuto if size == 0 { // for empty files, use the fileformat setting instead of // autodetection switch b.Settings["fileform...
@@ -409,6 +422,30 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT b.AddCursor(NewCursor(b, b.StartCursor)) b.GetActiveCursor().Relocate() + if command.SearchAfterStart { + // We can just search from current cursor and move it accordingly + // If the search text is empty FindN...
internal/buffer/buffer.go
26
Go
0.429
suggestion
99
51
51
false
micro: Handle +/text search text from args
3,767
zyedidia/micro
13,805
Go
dmaluka
luca020400
b.Settings["fileformat"] = "dos" } b.UpdateRules() // we know the filetype now, so update per-filetype settings config.UpdateFileTypeLocals(b.Settings, b.Settings["filetype"].(string)) if _, err := os.Stat(filepath.Join(config.ConfigDir, "buffers")); errors.Is(err, fs.ErrNotExist) { os.Mkdir(filepath.Join(co...
nit: Yes, `FindNext` won't do anything if the search text is empty, but it might be still cleaner to explicitly check it here as well, before doing anything? After all, it is a more typical case than a non-empty search text.
if !ok { return NewBufferFromString("", "", btype) } if !hasBackup { reader := bufio.NewReader(transform.NewReader(r, b.encoding.NewDecoder())) var ff FileFormat = FFAuto if size == 0 { // for empty files, use the fileformat setting instead of // autodetection switch b.Settings["filefor...
@@ -409,6 +422,30 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT b.AddCursor(NewCursor(b, b.StartCursor)) b.GetActiveCursor().Relocate() + if command.SearchAfterStart { + // We can just search from current cursor and move it accordingly + // If the search text is empty FindN...
internal/buffer/buffer.go
26
Go
0.571
nitpick
224
51
51
false
micro: Handle +/text search text from args
3,767
zyedidia/micro
13,805
Go
dmaluka
luca020400
b.Settings["fastdirty"] = true } else if !hasBackup { // since applying a backup does not save the applied backup to disk, we should // not calculate the original hash based on the backup data calcHash(b, &b.origHash) } } err = config.RunPluginFn("onBufferOpen", luar.New(ulua.L, b)) if err != nil { ...
```suggestion match, found, _ := b.FindNext(cmd.SearchRegex, b.Start(), b.End(), b.StartCursor, true, true) if found { if cmd.SearchAfterStart { // Search from current cursor and move it accordingly b.GetActiveCursor().SetSelectionStart(match[0]) b.GetActiveCursor().SetSelectionEnd(match[1]) ...
b.StartCursor = cmd.StartCursor } else if b.Settings["savecursor"].(bool) || b.Settings["saveundo"].(bool) { err := b.Unserialize() if err != nil { screen.TermMessage(err) } } b.AddCursor(NewCursor(b, b.StartCursor)) b.GetActiveCursor().Relocate() if cmd.SearchRegex != "" { match, found, _ := b.Find...
@@ -409,6 +422,31 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT b.AddCursor(NewCursor(b, b.StartCursor)) b.GetActiveCursor().Relocate() + if cmd.SearchRegex != "" { + if cmd.SearchAfterStart { + // We want to search from current cursor and move it accordingly + match, fo...
internal/buffer/buffer.go
26
Go
0.857
question
674
51
51
false
micro: Handle +/text search text from args
3,767
zyedidia/micro
13,805
Go
JoeKar
luca020400
action, more := binds.NextEvent(e, nil) if action != nil && !more { action(h) binds.ResetEvents() return true } else if action == nil && !more { binds.ResetEvents() } return more } func (h *BufPane) execAction(action BufAction, name string, te *tcell.EventMouse) bool { if name != "Autocomplete" && name !...
We add this now also for `BufKeyAction` too, right? Furthermore...is this optional argument really backward compatible? :thinking:
action(h) binds.ResetEvents() return true } else if action == nil && !more { binds.ResetEvents() } return more } func (h *BufPane) execAction(action BufAction, name string, te *tcell.EventMouse) bool { if name != "Autocomplete" && name != "CycleAutocompleteBack" { h.Buf.HasSuggestions = false } if !h....
@@ -570,7 +568,7 @@ func (h *BufPane) execAction(action BufAction, name string, te *tcell.EventMouse case BufMouseAction: success = a(h, te) } - success = success && h.PluginCB("on"+name) + success = success && h.PluginCB("on"+name, te)
internal/action/bufpane.go
26
Go
0.5
suggestion
132
51
51
false
Pass mouse info to {on,pre}MouseXXX callbacks
3,779
zyedidia/micro
13,805
Go
JoeKar
dmaluka
} } else if err != nil { InfoBar.Error(err) } } // SetLocalCmd sets an option local to the buffer func (h *BufPane) SetLocalCmd(args []string) { if len(args) < 2 { InfoBar.Error("Not enough arguments") return } option := args[0] value := args[1] err := h.Buf.SetOption(option, value) if err != nil { ...
Just "Not enough arguments", for consistency with other commands (including `togglelocal`?
} } else if err != nil { InfoBar.Error(err) } } // SetLocalCmd sets an option local to the buffer func (h *BufPane) SetLocalCmd(args []string) { if len(args) < 2 { InfoBar.Error("Not enough arguments") return } option := args[0] value := args[1] err := h.Buf.SetOption(option, value) if err != nil { ...
@@ -730,6 +732,63 @@ func (h *BufPane) SetLocalCmd(args []string) { } } +// ToggleCmd toggles an option +func (h *BufPane) ToggleCmd(args []string) { + if len(args) < 1 { + InfoBar.Error("Please provide an option to toggle")
internal/action/command.go
26
Go
0.357
question
90
51
51
false
Add toggle & togglelocal command
3,783
zyedidia/micro
13,805
Go
dmaluka
cutelisp
} option := args[0] value := args[1] err := h.Buf.SetOption(option, value) if err != nil { InfoBar.Error(err) } } // ToggleCmd toggles an option func (h *BufPane) ToggleCmd(args []string) { if len(args) < 1 { InfoBar.Error("Please provide an option to toggle") return } option := args[0] curVal := c...
We can just use type assertion.
} option := args[0] value := args[1] err := h.Buf.SetOption(option, value) if err != nil { InfoBar.Error(err) } } func (h *BufPane) toggleOption(option string, local bool) error { var curVal, newVal any if local { curVal = h.Buf.Settings[option] } else { curVal = config.GetGlobalOption(option) } if...
@@ -730,6 +732,63 @@ func (h *BufPane) SetLocalCmd(args []string) { } } +// ToggleCmd toggles an option +func (h *BufPane) ToggleCmd(args []string) { + if len(args) < 1 { + InfoBar.Error("Please provide an option to toggle") + return + } + + option := args[0] + curVal := config.GetGlobalOption(option) + if curV...
internal/action/command.go
26
Go
0.286
suggestion
31
51
51
false
Add toggle & togglelocal command
3,783
zyedidia/micro
13,805
Go
dmaluka
cutelisp
InfoBar.Error(err) } } // ToggleCmd toggles an option func (h *BufPane) ToggleCmd(args []string) { if len(args) < 1 { InfoBar.Error("Please provide an option to toggle") return } option := args[0] curVal := config.GetGlobalOption(option) if curVal == nil { InfoBar.Error(config.ErrInvalidOption) retur...
We can just use `SetGlobalOptionNative()`. No point in converting it to string just to convert it back from string inside `SetGlobalOption()`.
InfoBar.Error(err) } } func (h *BufPane) toggleOption(option string, local bool) error { var curVal, newVal any if local { curVal = h.Buf.Settings[option] } else { curVal = config.GetGlobalOption(option) } if curVal == nil { return config.ErrInvalidOption } if choices, ok := config.OptionChoices[opti...
@@ -730,6 +732,63 @@ func (h *BufPane) SetLocalCmd(args []string) { } } +// ToggleCmd toggles an option +func (h *BufPane) ToggleCmd(args []string) { + if len(args) < 1 { + InfoBar.Error("Please provide an option to toggle") + return + } + + option := args[0] + curVal := config.GetGlobalOption(option) + if curV...
internal/action/command.go
26
Go
0.571
suggestion
142
51
51
false
Add toggle & togglelocal command
3,783
zyedidia/micro
13,805
Go
dmaluka
cutelisp
err := h.Buf.SetOption(option, value) if err != nil { InfoBar.Error(err) } } else if err != nil { InfoBar.Error(err) } } // SetLocalCmd sets an option local to the buffer func (h *BufPane) SetLocalCmd(args []string) { if len(args) < 2 { InfoBar.Error("Not enough arguments") return } option := args...
Maybe "toggles a boolean option"?
err := h.Buf.SetOption(option, value) if err != nil { InfoBar.Error(err) } } else if err != nil { InfoBar.Error(err) } } // SetLocalCmd sets an option local to the buffer func (h *BufPane) SetLocalCmd(args []string) { if len(args) < 2 { InfoBar.Error("Not enough arguments") return } option := args...
@@ -730,6 +732,63 @@ func (h *BufPane) SetLocalCmd(args []string) { } } +// ToggleCmd toggles an option
internal/action/command.go
26
Go
0.071
question
33
51
51
false
Add toggle & togglelocal command
3,783
zyedidia/micro
13,805
Go
dmaluka
cutelisp
} curValBool, ok := curVal.(bool) if !ok { InfoBar.Error("Not a boolean option") return } err := SetGlobalOptionNative(option, !curValBool) if err == config.ErrInvalidOption { err := h.Buf.SetOptionNative(option, !curValBool) if err != nil { InfoBar.Error(err) } } } // ToggleLocalCmd toggles a b...
I think it's better to use `h.Buf.Settings[option]`, not just to avoid confusion when reading the code (although I understand the cause of this confusion is the confusing name of `GetGlobalOption()`, not your code), but also to check if this not a global-only option. With your current version, `togglelocal infobar` sil...
if choices, ok := config.OptionChoices[option]; ok && len(choices) == 2 { if curVal == choices[0] { newVal = choices[1] } else { newVal = choices[0] } } else if curValBool, ok := curVal.(bool); ok { newVal = !curValBool } else { return config.ErrOptNotToggleable } if local { if err := h.Buf.SetO...
@@ -732,58 +732,56 @@ func (h *BufPane) SetLocalCmd(args []string) { } } -// ToggleCmd toggles an option +// ToggleCmd toggles a boolean option func (h *BufPane) ToggleCmd(args []string) { if len(args) < 1 { - InfoBar.Error("Please provide an option to toggle") + InfoBar.Error("Not enough arguments") retur...
internal/action/command.go
26
Go
0.786
bug
541
51
51
false
Add toggle & togglelocal command
3,783
zyedidia/micro
13,805
Go
dmaluka
cutelisp
err := h.Buf.SetOption(option, value) if err != nil { InfoBar.Error(err) } } // ToggleCmd toggles an option func (h *BufPane) ToggleCmd(args []string) { if len(args) < 1 { InfoBar.Error("Please provide an option to toggle") return } option := args[0] curVal := config.GetGlobalOption(option) if curVal =...
Please remove unneeded spaces (and generally, use `gofmt`).
err := h.Buf.SetOption(option, value) if err != nil { InfoBar.Error(err) } } func (h *BufPane) toggleOption(option string, local bool) error { var curVal, newVal any if local { curVal = h.Buf.Settings[option] } else { curVal = config.GetGlobalOption(option) } if curVal == nil { return config.ErrInvali...
@@ -730,6 +732,63 @@ func (h *BufPane) SetLocalCmd(args []string) { } } +// ToggleCmd toggles an option +func (h *BufPane) ToggleCmd(args []string) { + if len(args) < 1 { + InfoBar.Error("Please provide an option to toggle") + return + } + + option := args[0] + curVal := config.GetGlobalOption(option) + if curV...
internal/action/command.go
26
Go
0.429
suggestion
59
51
51
false
Add toggle & togglelocal command
3,783
zyedidia/micro
13,805
Go
dmaluka
cutelisp
} } // ToggleCmd toggles a boolean option func (h *BufPane) ToggleCmd(args []string) { if len(args) < 1 { InfoBar.Error("Not enough arguments") return } option := args[0] curVal := config.GetGlobalOption(option) if curVal == nil { InfoBar.Error(config.ErrInvalidOption) return } curValBool, ok := curV...
I can remember https://github.com/zyedidia/micro/pull/3021#issuecomment-1806536539 :wink: Is there really the need to limit the (local) toggling to boolean options, since we could cycle through the other as well?
} } func (h *BufPane) toggleOption(option string, local bool) error { var curVal, newVal any if local { curVal = h.Buf.Settings[option] } else { curVal = config.GetGlobalOption(option) } if curVal == nil { return config.ErrInvalidOption } if choices, ok := config.OptionChoices[option]; ok && len(choice...
@@ -730,6 +732,61 @@ func (h *BufPane) SetLocalCmd(args []string) { } } +// ToggleCmd toggles a boolean option +func (h *BufPane) ToggleCmd(args []string) { + if len(args) < 1 { + InfoBar.Error("Not enough arguments") + return + } + + option := args[0] + curVal := config.GetGlobalOption(option) + if curVal == ni...
internal/action/command.go
26
Go
0.5
question
214
51
51
false
Add toggle & togglelocal command
3,783
zyedidia/micro
13,805
Go
JoeKar
cutelisp
// SetLocalCmd sets an option local to the buffer func (h *BufPane) SetLocalCmd(args []string) { if len(args) < 2 { InfoBar.Error("Not enough arguments") return } option := args[0] value := args[1] err := h.Buf.SetOption(option, value) if err != nil { InfoBar.Error(err) } } func (h *BufPane) toggleOptio...
Should we bother saying it's an invalid option or should we just say it's not a toggleable option anyway.
// SetLocalCmd sets an option local to the buffer func (h *BufPane) SetLocalCmd(args []string) { if len(args) < 2 { InfoBar.Error("Not enough arguments") return } option := args[0] value := args[1] err := h.Buf.SetOption(option, value) if err != nil { InfoBar.Error(err) } } func (h *BufPane) toggleOptio...
@@ -730,6 +732,64 @@ func (h *BufPane) SetLocalCmd(args []string) { } } +func (h *BufPane) toggleOption(option string, local bool) error { + var curVal, newVal any + + if local { + curVal = h.Buf.Settings[option] + } else { + curVal = config.GetGlobalOption(option) + } + if curVal == nil { + return config.ErrIn...
internal/action/command.go
26
Go
0.429
suggestion
105
51
51
false
Add toggle & togglelocal command
3,783
zyedidia/micro
13,805
Go
cutelisp
cutelisp
} if curVal == nil { return config.ErrInvalidOption } if choices, ok := config.OptionChoices[option]; ok && len(choices) == 2 { if curVal == choices[0] { newVal = choices[1] } else { newVal = choices[0] } } else if curValBool, ok := curVal.(bool); ok { newVal = !curValBool } else { return confi...
I took this logic from `SetCmd()`. ```go err := SetGlobalOption(option, value) if err == config.ErrInvalidOption { err := h.Buf.SetOption(option, value) if err != nil { InfoBar.Error(err) } } else if err != nil { InfoBar.Error(err) } ``` But now I wonder if making this fallback makes sense...
} if curVal == nil { return config.ErrInvalidOption } if choices, ok := config.OptionChoices[option]; ok && len(choices) == 2 { if curVal == choices[0] { newVal = choices[1] } else { newVal = choices[0] } } else if curValBool, ok := curVal.(bool); ok { newVal = !curValBool } else { return confi...
@@ -730,6 +732,64 @@ func (h *BufPane) SetLocalCmd(args []string) { } } +func (h *BufPane) toggleOption(option string, local bool) error { + var curVal, newVal any + + if local { + curVal = h.Buf.Settings[option] + } else { + curVal = config.GetGlobalOption(option) + } + if curVal == nil { + return config.ErrIn...
internal/action/command.go
26
Go
0.929
suggestion
710
51
51
false
Add toggle & togglelocal command
3,783
zyedidia/micro
13,805
Go
cutelisp
cutelisp
func (h *BufPane) toggleOption(option string, local bool) error { var curVal, newVal any if local { curVal = h.Buf.Settings[option] } else { curVal = config.GetGlobalOption(option) } if curVal == nil { return config.ErrInvalidOption } if choices, ok := config.OptionChoices[option]; ok && len(choices) ==...
nit: flip the order of the if/else branches (just to keep it the same as at the beginning of the function)?
func (h *BufPane) toggleOption(option string, local bool) error { var curVal, newVal any if local { curVal = h.Buf.Settings[option] } else { curVal = config.GetGlobalOption(option) } if curVal == nil { return config.ErrInvalidOption } if choices, ok := config.OptionChoices[option]; ok && len(choices) ==...
@@ -730,6 +732,65 @@ func (h *BufPane) SetLocalCmd(args []string) { } } +func (h *BufPane) toggleOption(option string, local bool) error { + var curVal, newVal any + + if local { + curVal = h.Buf.Settings[option] + } else { + curVal = config.GetGlobalOption(option) + } + if curVal == nil { + return config.ErrIn...
internal/action/command.go
26
Go
0.357
question
107
51
51
false
Add toggle & togglelocal command
3,783
zyedidia/micro
13,805
Go
dmaluka
cutelisp
func HashStringMd5(str string) string { return fmt.Sprintf("%x", md5.Sum([]byte(str))) } // EscapePathUrl encodes the path in URL query form func EscapePathUrl(path string) string { return url.QueryEscape(filepath.ToSlash(path)) } // EscapePathLegacy replaces every path separator in a given path with a % func Esca...
Why the last 16 characters, not the first 16 characters?
return fmt.Sprintf("%x", md5.Sum([]byte(str))) } // EscapePathUrl encodes the path in URL query form func EscapePathUrl(path string) string { return url.QueryEscape(filepath.ToSlash(path)) } // EscapePathLegacy replaces every path separator in a given path with a % func EscapePathLegacy(path string) string { path ...
@@ -474,9 +474,12 @@ func EscapePathLegacy(path string) string { // escaped using URL encoding or legacy encoding with '%' (for backward // compatibility, if the escaped path exists in the given directory). func DeterminePath(dir string, path string) string { - md5sum := filepath.Join(dir, HashStringMd5(path)) - if ...
internal/util/util.go
26
Go
0.214
question
56
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
type SerializedBuffer struct { EventHandler *EventHandler Cursor Loc ModTime time.Time } // Serialize serializes the buffer to config.ConfigDir/buffers func (b *Buffer) Serialize() error { if !b.Settings["savecursor"].(bool) && !b.Settings["saveundo"].(bool) { return nil } if b.Path == "" { return...
Still not addressed? Serialized buffers have the same issue as backups, should address them as well, right?
type SerializedBuffer struct { EventHandler *EventHandler Cursor Loc ModTime time.Time } // Serialize serializes the buffer to config.ConfigDir/buffers func (b *Buffer) Serialize() error { if !b.Settings["savecursor"].(bool) && !b.Settings["saveundo"].(bool) { return nil } if b.Path == "" { return...
@@ -39,7 +39,7 @@ func (b *Buffer) Serialize() error { return err } - name := util.DetermineEscapePath(filepath.Join(config.ConfigDir, "buffers"), b.AbsPath) + name, _ := util.DetermineEscapePath(filepath.Join(config.ConfigDir, "buffers"), b.AbsPath)
internal/buffer/serialize.go
26
Go
0.429
question
107
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
func EscapePathLegacy(path string) string { path = filepath.ToSlash(path) if runtime.GOOS == "windows" { // ':' is not valid in a path name on Windows but is ok on Unix path = strings.ReplaceAll(path, ":", "%") } return strings.ReplaceAll(path, "/", "%") } // DetermineEscapePath escapes a path, determining whe...
Why not just directly return the filename `hash + ".path"` instead of returning the hash and requiring the caller to append `.path` to it?
path = strings.ReplaceAll(path, ":", "%") } return strings.ReplaceAll(path, "/", "%") } // DetermineEscapePath escapes a path, determining whether it should be escaped // using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped...
@@ -469,18 +476,27 @@ func EscapePathLegacy(path string) string { // using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped // path exists in the given directory). -func DetermineEscapePath(dir string, path string) string { - u...
internal/util/util.go
26
Go
0.571
question
138
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
// Special cases like Windows Absolute path (C:\myfile.txt:10:5) are handled correctly. func GetPathAndCursorPosition(path string) (string, []string) { re := regexp.MustCompile(`([\s\S]+?)(?::(\d+))(?::(\d+))?$`) match := re.FindStringSubmatch(path) // no lines/columns were specified in the path, return just the pat...
We could probably use https://pkg.go.dev/encoding/hex#EncodeToString instead (although `fmt.Sprintf` is probably fine too).
// Special cases like Windows Absolute path (C:\myfile.txt:10:5) are handled correctly. func GetPathAndCursorPosition(path string) (string, []string) { re := regexp.MustCompile(`([\s\S]+?)(?::(\d+))(?::(\d+))?$`) match := re.FindStringSubmatch(path) // no lines/columns were specified in the path, return just the pat...
@@ -450,6 +453,10 @@ func AppendBackupSuffix(path string) string { return path + ".micro-backup" } +func HashStringMd5(str string) string { + return fmt.Sprintf("%x", md5.Sum([]byte(str)))
internal/util/util.go
26
Go
0.571
suggestion
123
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
// CommitHash is the commit this version was built on CommitHash = "Unknown" // CompileDate is the date this binary was compiled on CompileDate = "Unknown" // Debug logging Debug = "OFF" // FakeCursor is used to disable the terminal cursor and have micro // draw its own (enabled for windows consoles where the c...
These constants don't seem to be useful at all. Both are used in exactly one place anyway, and their names don't explain what they are for anyway. They don't seem to make the code clearer. I'd opt for keeping using hardcoded strings.
// CommitHash is the commit this version was built on CommitHash = "Unknown" // CompileDate is the date this binary was compiled on CompileDate = "Unknown" // Debug logging Debug = "OFF" // FakeCursor is used to disable the terminal cursor and have micro // draw its own (enabled for windows consoles where the c...
@@ -56,6 +56,9 @@ const FileMode os.FileMode = 0666 const fileNameLengthLimit int = 255 +const backupExtensionShort string = ".backup" +const backupExtensionLong string = ".micro-backup"
internal/util/util.go
26
Go
0.5
suggestion
233
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
func EscapePathUrl(path string) string { return url.QueryEscape(filepath.ToSlash(path)) } // EscapePathLegacy replaces every path separator in a given path with a % func EscapePathLegacy(path string) string { path = filepath.ToSlash(path) if runtime.GOOS == "windows" { // ':' is not valid in a path name on Window...
`DetermineEscapePath()` is more generic, it is not just for backups? The `.backup` extension wouldn't make a lot of sense for serialized buffers? So, do we need an extension at all? If the file name is just the hash, it suits to both backups and serialized buffers, and we can keep the code simple?
// EscapePathLegacy replaces every path separator in a given path with a % func EscapePathLegacy(path string) string { path = filepath.ToSlash(path) if runtime.GOOS == "windows" { // ':' is not valid in a path name on Windows but is ok on Unix path = strings.ReplaceAll(path, ":", "%") } return strings.ReplaceAl...
@@ -469,18 +476,27 @@ func EscapePathLegacy(path string) string { // using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped // path exists in the given directory). -func DetermineEscapePath(dir string, path string) string { - u...
internal/util/util.go
26
Go
0.571
security
301
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
} func HashStringMd5(str string) string { return fmt.Sprintf("%x", md5.Sum([]byte(str))) } // EscapePathUrl encodes the path in URL query form func EscapePathUrl(path string) string { return url.QueryEscape(filepath.ToSlash(path)) } // EscapePathLegacy replaces every path separator in a given path with a % func Es...
This line is a bit outdated, it doesn't describe what is actually returned as the 2nd return value?
func HashStringMd5(str string) string { return fmt.Sprintf("%x", md5.Sum([]byte(str))) } // EscapePathUrl encodes the path in URL query form func EscapePathUrl(path string) string { return url.QueryEscape(filepath.ToSlash(path)) } // EscapePathLegacy replaces every path separator in a given path with a % func Escap...
@@ -469,18 +474,27 @@ func EscapePathLegacy(path string) string { // using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped // path exists in the given directory). -func DetermineEscapePath(dir string, path string) string { - u...
internal/util/util.go
26
Go
0.214
question
99
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
// no lines/columns were specified in the path, return just the path with no cursor location if len(match) == 0 { return path, nil } else if match[len(match)-1] != "" { // if the last capture group match isn't empty then both line and column were provided return match[1], match[2:] } // if it was empty, then...
Just the hash, without any extension? Can't we just adjust `DetermineEscapePath()` to use `fileNameLengthLimit - len(".micro-backup")` instead of `fileNameLengthLimit` instead?
// no lines/columns were specified in the path, return just the path with no cursor location if len(match) == 0 { return path, nil } else if match[len(match)-1] != "" { // if the last capture group match isn't empty then both line and column were provided return match[1], match[2:] } // if it was empty, then...
@@ -447,8 +449,14 @@ func GetModTime(path string) (time.Time, error) { return info.ModTime(), nil } -func AppendBackupSuffix(path string) string { - return path + ".micro-backup" +func CreateTempBackupName(path string) string { + path += ".micro-backup" + name := filepath.Base(path) + if len(name) > fileNameLength...
internal/util/util.go
26
Go
0.571
security
179
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
func (b *SharedBuffer) writeBackup(path string) (string, error) { backupdir := b.backupDir() if _, err := os.Stat(backupdir); err != nil { if !errors.Is(err, fs.ErrNotExist) { return "", err } if err = os.Mkdir(backupdir, os.ModePerm); err != nil { return "", err } } name := util.DetermineEscapePath(...
> With this function we have the control about the actions to be done, when a backup is written or deleted, in one file. I can't parse this.
func (b *SharedBuffer) writeBackup(path string) (string, string, error) { backupdir := b.backupDir() if _, err := os.Stat(backupdir); err != nil { if !errors.Is(err, fs.ErrNotExist) { return "", "", err } if err = os.Mkdir(backupdir, os.ModePerm); err != nil { return "", "", err } } name, resolveName...
@@ -120,6 +120,10 @@ func (b *SharedBuffer) writeBackup(path string) (string, error) { return name, nil
internal/buffer/backup.go
26
Go
0.357
suggestion
144
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
func HashStringMd5(str string) string { return fmt.Sprintf("%x", md5.Sum([]byte(str))) } // EscapePathUrl encodes the path in URL query form func EscapePathUrl(path string) string { return url.QueryEscape(filepath.ToSlash(path)) } // EscapePathLegacy replaces every path separator in a given path with a % func Esca...
"it is hashed" sounds like the escaped path, not the original path, is hashed.
return fmt.Sprintf("%x", md5.Sum([]byte(str))) } // EscapePathUrl encodes the path in URL query form func EscapePathUrl(path string) string { return url.QueryEscape(filepath.ToSlash(path)) } // EscapePathLegacy replaces every path separator in a given path with a % func EscapePathLegacy(path string) string { path ...
@@ -469,18 +474,30 @@ func EscapePathLegacy(path string) string { // using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped // path exists in the given directory). -func DetermineEscapePath(dir string, path string) string { - u...
internal/util/util.go
26
Go
0.214
security
78
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
return fmt.Sprintf("%x", md5.Sum([]byte(str))) } // EscapePathUrl encodes the path in URL query form func EscapePathUrl(path string) string { return url.QueryEscape(filepath.ToSlash(path)) } // EscapePathLegacy replaces every path separator in a given path with a % func EscapePathLegacy(path string) string { path ...
This last sentence sounds fancy but not quite clear. Let's describe this clearly, e.g.: "In case the length of the escaped path (plus the backup extension) exceeds the filename length limit, a hash of the path is returned instead. In such case the second return value is the name of a file the original path should...
// EscapePathUrl encodes the path in URL query form func EscapePathUrl(path string) string { return url.QueryEscape(filepath.ToSlash(path)) } // EscapePathLegacy replaces every path separator in a given path with a % func EscapePathLegacy(path string) string { path = filepath.ToSlash(path) if runtime.GOOS == "wind...
@@ -469,18 +474,30 @@ func EscapePathLegacy(path string) string { // using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped // path exists in the given directory). -func DetermineEscapePath(dir string, path string) string { - u...
internal/util/util.go
26
Go
0.5
security
446
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
// DetermineEscapePath escapes a path, determining whether it should be escaped // using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped // path exists in the given directory). // In case the escaped path, including the backup e...
We shouldn't return a resolve path if we return a legacy escaped path, right? Well, in such case `fresolve` is gonna be `""` anyway, but it's cleaner to explicitly return `""`. ...Actually the code looks a bit messy overall. Why not keep it readable: ```go url := filepath.Join(dir, EscapePathUrl(path)) if ...
// using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped // path exists in the given directory). // In case the length of the escaped path (plus the backup extension) exceeds // the filename length limit, a hash of the path is re...
@@ -469,18 +474,30 @@ func EscapePathLegacy(path string) string { // using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped // path exists in the given directory). -func DetermineEscapePath(dir string, path string) string { - u...
internal/util/util.go
26
Go
0.857
security
658
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
return url.QueryEscape(filepath.ToSlash(path)) } // EscapePathLegacy replaces every path separator in a given path with a % func EscapePathLegacy(path string) string { path = filepath.ToSlash(path) if runtime.GOOS == "windows" { // ':' is not valid in a path name on Windows but is ok on Unix path = strings.Repl...
Now, `.micro-backup` becomes hardcoded not in one but in two places, so it might be good to declare a constant for it. (This is rather nit, but still.) Or, instead of declaring a constant we could do `if len(AppendBackupSuffix(fname)) > 255`... But to me it feels better to throw away `AppendBackupSuffix()` and add a...
// EscapePathLegacy replaces every path separator in a given path with a % func EscapePathLegacy(path string) string { path = filepath.ToSlash(path) if runtime.GOOS == "windows" { // ':' is not valid in a path name on Windows but is ok on Unix path = strings.ReplaceAll(path, ":", "%") } return strings.ReplaceA...
@@ -469,18 +474,30 @@ func EscapePathLegacy(path string) string { // using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped // path exists in the given directory). -func DetermineEscapePath(dir string, path string) string { - u...
internal/util/util.go
26
Go
0.643
suggestion
426
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
if runtime.GOOS == "windows" { // ':' is not valid in a path name on Windows but is ok on Unix path = strings.ReplaceAll(path, ":", "%") } return strings.ReplaceAll(path, "/", "%") } // DetermineEscapePath escapes a path, determining whether it should be escaped // using URL encoding (preferred, since it encode...
Did you test it? It creates the backup in the current directory, not in `~/.config/micro/backups/` (only `{hash}.path` is created in `~/.config/micro/backups/`). The result is not just bad (the file is not recovered from the backup afterwards) but worse: the serialized buffer file is created in the current directory...
path = strings.ReplaceAll(path, ":", "%") } return strings.ReplaceAll(path, "/", "%") } // DetermineEscapePath escapes a path, determining whether it should be escaped // using URL encoding (preferred, since it encodes unambiguously) or // legacy encoding with '%' (for backward compatibility, if the legacy-escaped...
@@ -480,6 +487,10 @@ func DetermineEscapePath(dir string, path string) string { return legacy } + if len(url)+len(".micro-backup") > 255 { + return HashStringMd5(path)
internal/util/util.go
26
Go
1
security
1,368
51
51
false
backup+util: Prevent too long backup file names with hashing + resolve file
3,806
zyedidia/micro
13,805
Go
dmaluka
JoeKar
} backupName := util.DetermineEscapePath(backupDir, path) _, err = b.overwriteFile(backupName) if err != nil { os.Remove(backupName) return 0, err } b.forceKeepBackup = true size, err := file.Write(b) if err != nil { err = util.OverwriteError{err, backupName} file.Close() return size, err } b.forc...
Good catch. But why just here? What about all other error returns above, where we also leak `file`?
// backup file first. func (b *Buffer) safeWrite(path string, withSudo bool, newFile bool) (int, error) { file, err := openFile(path, withSudo) if err != nil { return 0, err } defer func() { if newFile && err != nil { os.Remove(path) } }() // Try to backup first before writing backupName, err := b.wr...
@@ -374,6 +374,7 @@ func (b *Buffer) safeWrite(path string, withSudo bool, newFile bool) (int, error size, err := file.Write(b) if err != nil { err = util.OverwriteError{err, backupName} + file.Close()
internal/buffer/save.go
26
Go
0.5
question
99
30
45
false
Adding missing file closes
3,807
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
if !b.Settings["fastdirty"].(bool) { if result.size > LargeFileThreshold { // For large files 'fastdirty' needs to be on b.Settings["fastdirty"] = true } else { calcHash(b, &b.origHash) } } newPath := b.Path != filename b.Path = filename b.AbsPath = absFilename b.isModified = false b.UpdateModTi...
`writeBackup()`? `backupFile()` is not the most suitable name here (for example, because if `backupFile()` backs up a file, one would expect that `backupDir()` backs up a directory), right?
if !b.Settings["fastdirty"].(bool) { if result.size > LargeFileThreshold { // For large files 'fastdirty' needs to be on b.Settings["fastdirty"] = true } else { calcHash(b, &b.origHash) } } newPath := b.Path != filename b.Path = filename b.AbsPath = absFilename b.isModified = false b.UpdateModTi...
@@ -337,6 +337,27 @@ func (b *Buffer) saveToFile(filename string, withSudo bool, autoSave bool) error return err } +func (b *Buffer) backupFile(path string) (string, error) {
internal/buffer/save.go
26
Go
0.571
question
189
51
51
false
Adding missing file closes
3,807
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
// contents of the file if it fails to write the new contents. // This means that the file is not overwritten directly but by writing to the // backup file first. func (b *Buffer) safeWrite(path string, withSudo bool, newFile bool) (int, error) { file, err := openFile(path, withSudo) if err != nil { return 0, err ...
Is this just to avoid having `err2`? Why avoid that?
// contents of the file if it fails to write the new contents. // This means that the file is not overwritten directly but by writing to the // backup file first. func (b *Buffer) safeWrite(path string, withSudo bool, newFile bool) (int, error) { file, err := openFile(path, withSudo) if err != nil { return 0, err ...
@@ -353,39 +374,36 @@ func (b *Buffer) safeWrite(path string, withSudo bool, newFile bool) (int, error } }() - backupDir := b.backupDir() - if _, err := os.Stat(backupDir); err != nil { - if !errors.Is(err, fs.ErrNotExist) { - return 0, err - } - if err = os.Mkdir(backupDir, os.ModePerm); err != nil { - r...
internal/buffer/save.go
26
Go
0.429
question
52
49
47
false
Adding missing file closes
3,807
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
return 0, err } defer func() { if newFile && err != nil { os.Remove(path) } }() b.forceKeepBackup = true size := 0 // Try to backup first before writing backupName, err := b.backupFile(path) if err != nil { file.Close() return 0, err } { // If we failed to write or close, keep the backup we...
We can just `return 0, util.OverwriteError{err, backupName}`?
return 0, err } defer func() { if newFile && err != nil { os.Remove(path) } }() // Try to backup first before writing backupName, err := b.writeBackup(path) if err != nil { file.Close() return 0, err } b.forceKeepBackup = true size := 0 { // If we failed to write or close, keep the backup w...
@@ -353,39 +374,36 @@ func (b *Buffer) safeWrite(path string, withSudo bool, newFile bool) (int, error } }() - backupDir := b.backupDir() - if _, err := os.Stat(backupDir); err != nil { - if !errors.Is(err, fs.ErrNotExist) { - return 0, err - } - if err = os.Mkdir(backupDir, os.ModePerm); err != nil { - r...
internal/buffer/save.go
26
Go
0.5
question
61
43
41
false
Adding missing file closes
3,807
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
_, err := b.overwriteFile(backupName) if err != nil { os.Remove(backupName) return "", err } return backupName, nil } // safeWrite writes the buffer to a file in a "safe" way, preventing loss of the // contents of the file if it fails to write the new contents. // This means that the file is not overwritten d...
Why move setting `forceKeepBackup` here? We force keeping the backup in case we actually have successfully created this backup, right?
_, err := b.overwriteFile(backupName) if err != nil { os.Remove(backupName) return "", err } return backupName, nil } // safeWrite writes the buffer to a file in a "safe" way, preventing loss of the // contents of the file if it fails to write the new contents. // This means that the file is not overwritten d...
@@ -353,39 +374,36 @@ func (b *Buffer) safeWrite(path string, withSudo bool, newFile bool) (int, error } }() - backupDir := b.backupDir() - if _, err := os.Stat(backupDir); err != nil { - if !errors.Is(err, fs.ErrNotExist) { - return 0, err - } - if err = os.Mkdir(backupDir, os.ModePerm); err != nil { - r...
internal/buffer/save.go
26
Go
0.571
question
134
51
51
false
Adding missing file closes
3,807
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
h.DoRuneInsert(t) case BufKeyAction: t(h) } } h.Relocate() return true } // SpawnMultiCursor creates a new multiple cursor at the next occurrence of the current selection or current word func (h *BufPane) SpawnMultiCursor() bool { spawner := h.Buf.GetCursor(h.Buf.NumCursors() - 1) if !spawner.HasSelecti...
Added by accident in this commit? :thinking:
h.DoRuneInsert(t) case BufKeyAction: t(h) } } h.Relocate() return true } // SpawnMultiCursor creates a new multiple cursor at the next occurrence of the current selection or current word func (h *BufPane) SpawnMultiCursor() bool { spawner := h.Buf.GetCursor(h.Buf.NumCursors() - 1) if !spawner.HasSelecti...
@@ -2126,6 +2126,13 @@ func (h *BufPane) SpawnMultiCursor() bool { return true } + // Move the cursor to the beginning of the selection + if spawner.LessThan(spawner.CurSelection[0]) { + spawner.GotoLoc(spawner.CurSelection[0]) + } + if spawner.LessThan(spawner.CurSelection[1]) { + spawner.GotoLoc(spawner.CurS...
internal/action/actions.go
26
Go
0.071
suggestion
45
51
51
false
Adding the ability to differentiate builtin plugins when listing
3,810
zyedidia/micro
13,805
Go
JoeKar
Neko-Box-Coder
if !p.IsLoaded() || (settings != nil && settings[p.Name] == false) { continue } val, err := p.Call(fn, args...) if err == ErrNoSuchFunction { continue } if err != nil { reterr = errors.New("Plugin " + p.Name + ": " + err.Error()) continue } if v, ok := val.(lua.LBool); ok { retbool = retb...
gofmt And, what @JoeKar said in https://github.com/zyedidia/micro/pull/3810#issuecomment-3103645607 when advocating for renaming it: "It wouldn't require the additional comment."? ...IMHO `Default` is a fine name. But since you guys are eager to rename it, I'm fine with that too.
if !p.IsLoaded() || (settings != nil && settings[p.Name] == false) { continue } val, err := p.Call(fn, args...) if err == ErrNoSuchFunction { continue } if err != nil { reterr = errors.New("Plugin " + p.Name + ": " + err.Error()) continue } if v, ok := val.(lua.LBool); ok { retbool = retb...
@@ -71,7 +71,7 @@ type Plugin struct { Info *PluginInfo // json file containing info Srcs []RuntimeFile // lua files Loaded bool - Default bool // pre-installed plugin + Builtin bool // pre-installed plugin
internal/config/plugin.go
26
Go
0.643
style
286
51
51
false
Adding the ability to differentiate builtin plugins when listing
3,810
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
} else if err := pp.IsInstallable(out); err != nil { fmt.Fprintln(out, "Error installing ", plugin, ": ", err) } else { for _, installed := range installedVersions { if pp.Name == installed.Pack().Name { if pp.Versions[0].Version.Compare(installed.Version) == 1 { fmt.Fprintln(out, pp.Nam...
And if this is initlua? Although, this part is already buggy without this PR.
} else if err := pp.IsInstallable(out); err != nil { fmt.Fprintln(out, "Error installing ", plugin, ": ", err) } else { for _, installed := range installedVersions { if pp.Name == installed.Pack().Name { if pp.Versions[0].Version.Compare(installed.Version) == 1 { fmt.Fprintln(out, pp.Nam...
@@ -665,7 +670,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) { for _, plugin := range args { // check if the plugin exists. for _, p := range Plugins { - if p.Name == plugin && p.Default { + if p.Name == plugin && p.Builtin {
internal/config/plugin_installer.go
26
Go
0.357
bug
80
51
51
false
Adding the ability to differentiate builtin plugins when listing
3,810
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
pp := GetAllPluginPackages(out).Get(plugin) if pp == nil { fmt.Fprintln(out, "Unknown plugin \""+plugin+"\"") } else if err := pp.IsInstallable(out); err != nil { fmt.Fprintln(out, "Error installing ", plugin, ": ", err) } else { for _, installed := range installedVersions { if pp.Name == i...
If we are renaming "default" to "built-in" all over the place anyway, don't we update to update this log message as well?
pp := GetAllPluginPackages(out).Get(plugin) if pp == nil { fmt.Fprintln(out, "Unknown plugin \""+plugin+"\"") } else if err := pp.IsInstallable(out); err != nil { fmt.Fprintln(out, "Error installing ", plugin, ": ", err) } else { for _, installed := range installedVersions { if pp.Name == i...
@@ -665,7 +670,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) { for _, plugin := range args { // check if the plugin exists. for _, p := range Plugins { - if p.Name == plugin && p.Default { + if (p.Name == plugin && p.Builtin) || p.Name == "initlua" { fmt.Fprintln(out, "Default...
internal/config/plugin_installer.go
26
Go
0.357
question
121
51
51
false
Adding the ability to differentiate builtin plugins when listing
3,810
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
for _, plugin := range args { pp := GetAllPluginPackages(out).Get(plugin) if pp == nil { fmt.Fprintln(out, "Unknown plugin \""+plugin+"\"") } else if err := pp.IsInstallable(out); err != nil { fmt.Fprintln(out, "Error installing ", plugin, ": ", err) } else { for _, installed := range installe...
1. Now, when _successfully_ removing _any_ plugin, micro prints "Default plugins cannot be removed..." Although the plugin still ends up being successfully removed, thanks to `continue` (BTW I'm not sure why we have `continue` instead of `break` here). 2. What about `UpdatePlugins()`?
for _, plugin := range args { pp := GetAllPluginPackages(out).Get(plugin) if pp == nil { fmt.Fprintln(out, "Unknown plugin \""+plugin+"\"") } else if err := pp.IsInstallable(out); err != nil { fmt.Fprintln(out, "Error installing ", plugin, ": ", err) } else { for _, installed := range installe...
@@ -665,7 +670,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) { for _, plugin := range args { // check if the plugin exists. for _, p := range Plugins { - if p.Name == plugin && p.Default { + if (p.Name == plugin && p.Builtin) || p.Name == "initlua" {
internal/config/plugin_installer.go
26
Go
0.643
question
291
51
51
false
Adding the ability to differentiate builtin plugins when listing
3,810
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
// check if the plugin exists. for _, p := range Plugins { if (p.Name == plugin && p.Builtin) || p.Name == "initlua" { fmt.Fprintln(out, "Default plugins cannot be removed, but can be disabled via settings.") continue } if p.Name == plugin { UninstallPlugin(out, plugin) removed += ...
nit: just to keep it in line with the below printfs, we could `fmt.Fprintf(out, "%s\n", p.Pack().Name)`
if plugin == "initlua" { fmt.Fprintln(out, "initlua cannot be removed, but can be disabled via settings.") continue } // check if the plugin exists. for _, p := range Plugins { if p.Name == plugin && p.Builtin { fmt.Fprintln(out, p.Name, "is a built-in plugin which cannot be removed, but ca...
@@ -687,7 +692,13 @@ func PluginCommand(out io.Writer, cmd string, args []string) { plugins := GetInstalledVersions(false) fmt.Fprintln(out, "The following plugins are currently installed:") for _, p := range plugins { - fmt.Fprintf(out, "%s (%s)\n", p.Pack().Name, p.Version) + if p.Pack().Name == "initlua...
internal/config/plugin_installer.go
26
Go
0.571
nitpick
103
51
51
false
Adding the ability to differentiate builtin plugins when listing
3,810
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
} else { for _, installed := range installedVersions { if pp.Name == installed.Pack().Name { if pp.Versions[0].Version.Compare(installed.Version) == 1 { fmt.Fprintln(out, pp.Name, " is already installed but out-of-date: use 'plugin update ", pp.Name, "' to update") } else { fmt.Fpr...
If you really want to change it to `break` right away, what about the other `continue` below, in the successful case? And before you rush to change it to `break` as well: have you investigated what exactly would be the consequences of these changes? What if there actually are multiple plugins with the same name? We ...
} else { for _, installed := range installedVersions { if pp.Name == installed.Pack().Name { if pp.Versions[0].Version.Compare(installed.Version) == 1 { fmt.Fprintln(out, pp.Name, " is already installed but out-of-date: use 'plugin update ", pp.Name, "' to update") } else { fmt.Fpr...
@@ -668,11 +668,15 @@ func PluginCommand(out io.Writer, cmd string, args []string) { case "remove": removed := "" for _, plugin := range args { + if plugin == "initlua" { + fmt.Fprintln(out, "initlua cannot be removed, but can be disabled via settings.") + continue + } // check if the plugin exist...
internal/config/plugin_installer.go
26
Go
0.643
suggestion
707
51
51
false
Adding the ability to differentiate builtin plugins when listing
3,810
zyedidia/micro
13,805
Go
dmaluka
Neko-Box-Coder
pp := GetAllPluginPackages(out).Get(plugin) if pp == nil { fmt.Fprintln(out, "Unknown plugin \""+plugin+"\"") } else if err := pp.IsInstallable(out); err != nil { fmt.Fprintln(out, "Error installing ", plugin, ": ", err) } else { for _, installed := range installedVersions { if pp.Name == i...
When running `-plugin remove comment literate`, this message is printed multiple times, which looks a bit odd IMO. Why we show a generic error message ? Wouldn't it be better to specify which of the provided plugins are built-in? Also, it would be helpful to display a clearer message when trying to remove a plugi...
pp := GetAllPluginPackages(out).Get(plugin) if pp == nil { fmt.Fprintln(out, "Unknown plugin \""+plugin+"\"") } else if err := pp.IsInstallable(out); err != nil { fmt.Fprintln(out, "Error installing ", plugin, ": ", err) } else { for _, installed := range installedVersions { if pp.Name == i...
@@ -665,8 +670,8 @@ func PluginCommand(out io.Writer, cmd string, args []string) { for _, plugin := range args { // check if the plugin exists. for _, p := range Plugins { - if p.Name == plugin && p.Default { - fmt.Fprintln(out, "Default plugins cannot be removed, but can be disabled via settings.") +...
internal/config/plugin_installer.go
26
Go
0.786
question
424
51
51
false
Adding the ability to differentiate builtin plugins when listing
3,810
zyedidia/micro
13,805
Go
cutelisp
Neko-Box-Coder
select { case sr := <-saveRequestChan: size, err := sr.buf.safeWrite(sr.path, sr.withSudo, sr.newFile) sr.saveResponseChan <- saveResponse{size, err} case <-backupTicker.C: for len(backupRequestChan) > 0 { b := <-backupRequestChan bfini := atomic.LoadInt32(&(b.fini)) != 0 if !bfini {...
So this commit introduces a regression (fixed only in the following commits)?
for { select { case sr := <-saveRequestChan: size, err := sr.buf.safeWrite(sr.path, sr.withSudo, sr.newFile) sr.saveResponseChan <- saveResponse{size, err} case <-backupTicker.C: for len(backupRequestChan) > 0 { b := <-backupRequestChan bfini := atomic.LoadInt32(&(b.fini)) != 0 if ...
@@ -83,7 +83,7 @@ func openFile(name string, withSudo bool) (wrappedFile, error) { var sigChan chan os.Signal if withSudo { - cmd = exec.Command(config.GlobalSettings["sucmd"].(string), "dd", "bs=4k", "of="+name) + cmd = exec.Command(config.GlobalSettings["sucmd"].(string), "dd", "bs=4k", "conv=notrunc", "of="+...
internal/buffer/save.go
26
Go
0.214
question
77
51
51
false
save: Use `dd` with the `notrunc` & `fsync` and postpone truncation
3,814
zyedidia/micro
13,805
Go
dmaluka
JoeKar
if err != nil { screen.TempStart(screenb) signal.Notify(util.Sigterm, os.Interrupt) signal.Stop(sigChan) return wrappedFile{}, err } } else { writeCloser, err = os.OpenFile(name, os.O_WRONLY|os.O_CREATE, util.FileMode) if err != nil { return wrappedFile{}, err } } return wrappedFile{name,...
The screen should be already stopped by `openFile()`, right? So we don't need to call `TempFini()/TempStart()` here (they do nothing here anyway)?
screenb = screen.TempFini() // need to start the process now, otherwise when we flush the file // contents to its stdin it might hang because the kernel's pipe size // is too small to handle the full file contents all at once err = cmd.Start() if err != nil { screen.TempStart(screenb) signal.Notify(u...
@@ -113,12 +115,35 @@ func openFile(name string, withSudo bool) (wrappedFile, error) { } } - return wrappedFile{writeCloser, withSudo, screenb, cmd, sigChan}, nil + return wrappedFile{name, writeCloser, withSudo, screenb, cmd, sigChan}, nil } func (wf wrappedFile) Truncate(size int64) error { if wf.withSud...
internal/buffer/save.go
26
Go
0.571
question
146
51
51
false
save: Use `dd` with the `notrunc` & `fsync` and postpone truncation
3,814
zyedidia/micro
13,805
Go
dmaluka
JoeKar
err = cmd.Start() if err != nil { screen.TempStart(screenb) signal.Notify(util.Sigterm, os.Interrupt) signal.Stop(sigChan) return wrappedFile{}, err } } else { writeCloser, err = os.OpenFile(name, os.O_WRONLY|os.O_CREATE, util.FileMode) if err != nil { return wrappedFile{}, err } } retu...
We have already attached SIGINT to `wf.sigChan` in `openFile()`, and we only detach it when we are done in `wrappedFile.Close()`, right? So why re-attach it to this temporary `sigChan` in the middle? (And you know what your `signal.Notify(util.Sigterm, os.Interrupt)` at line 143 in this function is doing? It defeats...
screenb = screen.TempFini() // need to start the process now, otherwise when we flush the file // contents to its stdin it might hang because the kernel's pipe size // is too small to handle the full file contents all at once err = cmd.Start() if err != nil { screen.TempStart(screenb) signal.Notify(...
@@ -113,12 +115,35 @@ func openFile(name string, withSudo bool) (wrappedFile, error) { } } - return wrappedFile{writeCloser, withSudo, screenb, cmd, sigChan}, nil + return wrappedFile{name, writeCloser, withSudo, screenb, cmd, sigChan}, nil } func (wf wrappedFile) Truncate(size int64) error { if wf.withSud...
internal/buffer/save.go
26
Go
0.643
suggestion
536
51
51
false
save: Use `dd` with the `notrunc` & `fsync` and postpone truncation
3,814
zyedidia/micro
13,805
Go
dmaluka
JoeKar
err := cmd.Start() if err != nil { screen.TempStart(screenb) signal.Notify(util.Sigterm, os.Interrupt) signal.Stop(sigChan) return err } err = cmd.Wait() screen.TempStart(screenb) signal.Notify(util.Sigterm, os.Interrupt) signal.Stop(sigChan) return err } return wf.writeCloser.(*os.F...
What is this for? Can't we just use `conv=fsync` as you originally intended? Is this just to have this "nice" `Sync()` method? The consequence of having it is that we run sudo not even 2 times (for `dd` and for `truncate`) but 3 times. So if the sudo timeout is disabled (`timestamp_timeout` set to 0 in `/etc/sudo...
// by openFile() // truncate might not be available on every platfom, so use dd instead cmd := exec.Command(config.GlobalSettings["sucmd"].(string), "dd", "count=0", "of="+wf.name) return cmd.Run() } return wf.writeCloser.(*os.File).Truncate(0) } func (wf wrappedFile) Write(b *Buffer) (int, error) { file :=...
@@ -151,7 +151,30 @@ func (wf wrappedFile) Truncate(size int64) error { func (wf wrappedFile) Sync() error { // Call Sync() on the file to make sure the content is safely on disk. if wf.withSudo { - return nil + cmd := exec.Command(config.GlobalSettings["sucmd"].(string), "sync", wf.name)
internal/buffer/save.go
26
Go
0.643
question
526
51
51
false
save: Use `dd` with the `notrunc` & `fsync` and postpone truncation
3,814
zyedidia/micro
13,805
Go
dmaluka
JoeKar
// contents to its stdin it might hang because the kernel's pipe size // is too small to handle the full file contents all at once err = cmd.Start() if err != nil { screen.TempStart(screenb) signal.Notify(util.Sigterm, os.Interrupt) signal.Stop(sigChan) return wrappedFile{}, err } } else { wr...
I checked all Unix platforms in `cross-compile.sh` and only 3 platforms don't have `truncate` as a command, which are [Illumos](https://www.illumos.org/man/1/truncate), [NetBSD](https://man.netbsd.org/truncate.1), and [OpenBSD](https://man.openbsd.org/truncate.1). If we will replace the `truncate` command, `dd count...
signal.Reset(os.Interrupt) signal.Notify(sigChan, os.Interrupt) screenb = screen.TempFini() // need to start the process now, otherwise when we flush the file // contents to its stdin it might hang because the kernel's pipe size // is too small to handle the full file contents all at once err = cmd.Start...
@@ -113,7 +115,17 @@ func openFile(name string, withSudo bool) (wrappedFile, error) { } } - return wrappedFile{writeCloser, withSudo, screenb, cmd, sigChan}, nil + return wrappedFile{name, writeCloser, withSudo, screenb, cmd, sigChan}, nil +} + +func (wf wrappedFile) Truncate(size int64) error { + if wf.withSudo...
internal/buffer/save.go
26
Go
0.643
suggestion
597
51
51
false
save: Use `dd` with the `notrunc` & `fsync` and postpone truncation
3,814
zyedidia/micro
13,805
Go
niten94
JoeKar
signal.Notify(sigChan, os.Interrupt) screenb = screen.TempFini() // need to start the process now, otherwise when we flush the file // contents to its stdin it might hang because the kernel's pipe size // is too small to handle the full file contents all at once err = cmd.Start() if err != nil { scree...
The `size` argument not used anymore? (It was not really needed in the first place, but now it is not even used.)
if err != nil { return wrappedFile{}, err } sigChan = make(chan os.Signal, 1) signal.Reset(os.Interrupt) signal.Notify(sigChan, os.Interrupt) screenb = screen.TempFini() // need to start the process now, otherwise when we flush the file // contents to its stdin it might hang because the kernel's pi...
@@ -113,7 +114,17 @@ func openFile(name string, withSudo bool) (wrappedFile, error) { } } - return wrappedFile{writeCloser, withSudo, screenb, cmd, sigChan}, nil + return wrappedFile{name, writeCloser, withSudo, screenb, cmd, sigChan}, nil +} + +func (wf wrappedFile) Truncate(size int64) error {
internal/buffer/save.go
26
Go
0.571
suggestion
113
51
51
false
save: Use `dd` with the `notrunc` & `fsync` and postpone truncation
3,814
zyedidia/micro
13,805
Go
dmaluka
JoeKar
signal.Notify(util.Sigterm, os.Interrupt) signal.Stop(sigChan) return wrappedFile{}, err } } else { writeCloser, err = os.OpenFile(name, os.O_WRONLY|os.O_CREATE, util.FileMode) if err != nil { return wrappedFile{}, err } } return wrappedFile{name, writeCloser, withSudo, screenb, cmd, sigChan},...
Add a comment about why we don't use `truncate`?
// need to start the process now, otherwise when we flush the file // contents to its stdin it might hang because the kernel's pipe size // is too small to handle the full file contents all at once err = cmd.Start() if err != nil { screen.TempStart(screenb) signal.Notify(util.Sigterm, os.Interrupt) ...
@@ -113,7 +114,17 @@ func openFile(name string, withSudo bool) (wrappedFile, error) { } } - return wrappedFile{writeCloser, withSudo, screenb, cmd, sigChan}, nil + return wrappedFile{name, writeCloser, withSudo, screenb, cmd, sigChan}, nil +} + +func (wf wrappedFile) Truncate(size int64) error { + if wf.withSudo...
internal/buffer/save.go
26
Go
0.286
question
48
51
51
false
save: Use `dd` with the `notrunc` & `fsync` and postpone truncation
3,814
zyedidia/micro
13,805
Go
dmaluka
JoeKar
// contents to its stdin it might hang because the kernel's pipe size // is too small to handle the full file contents all at once err = cmd.Start() if err != nil { screen.TempStart(screenb) signal.Notify(util.Sigterm, os.Interrupt) signal.Stop(sigChan) return wrappedFile{}, err } } else { wr...
We can drop `if=/dev/zero` (thus avoid unneeded assumption about the presence of /dev/zero)? It doesn't matter where we "read" 0 bytes from, so we can just read them from stdin.
sigChan = make(chan os.Signal, 1) signal.Reset(os.Interrupt) signal.Notify(sigChan, os.Interrupt) screenb = screen.TempFini() // need to start the process now, otherwise when we flush the file // contents to its stdin it might hang because the kernel's pipe size // is too small to handle the full file co...
@@ -113,7 +114,17 @@ func openFile(name string, withSudo bool) (wrappedFile, error) { } } - return wrappedFile{writeCloser, withSudo, screenb, cmd, sigChan}, nil + return wrappedFile{name, writeCloser, withSudo, screenb, cmd, sigChan}, nil +} + +func (wf wrappedFile) Truncate(size int64) error { + if wf.withSudo...
internal/buffer/save.go
26
Go
0.571
suggestion
177
51
51
false
save: Use `dd` with the `notrunc` & `fsync` and postpone truncation
3,814
zyedidia/micro
13,805
Go
dmaluka
JoeKar
select { case sr := <-saveRequestChan: size, err := sr.buf.safeWrite(sr.path, sr.withSudo, sr.newFile) sr.saveResponseChan <- saveResponse{size, err} case <-backupTicker.C: for len(backupRequestChan) > 0 { b := <-backupRequestChan bfini := atomic.LoadInt32(&(b.fini)) != 0 if !bfini {...
I forgot to check this, but `conv=fsync` seems to be unsupported only on [NetBSD](https://man.netbsd.org/dd.1#DESCRIPTION) and [Illumos](https://www.illumos.org/man/8/dd). Maybe run `dd` without `conv=fsync` on both platforms and add a TODO comment?
select { case sr := <-saveRequestChan: size, err := sr.buf.safeWrite(sr.path, sr.withSudo, sr.newFile) sr.saveResponseChan <- saveResponse{size, err} case <-backupTicker.C: for len(backupRequestChan) > 0 { b := <-backupRequestChan bfini := atomic.LoadInt32(&(b.fini)) != 0 if !bfini {...
@@ -83,7 +84,7 @@ func openFile(name string, withSudo bool) (wrappedFile, error) { var sigChan chan os.Signal if withSudo { - cmd = exec.Command(config.GlobalSettings["sucmd"].(string), "dd", "bs=4k", "of="+name) + cmd = exec.Command(config.GlobalSettings["sucmd"].(string), "dd", "bs=4k", "conv=notrunc,fsync", ...
internal/buffer/save.go
26
Go
0.571
question
249
51
51
false
save: Use `dd` with the `notrunc` & `fsync` and postpone truncation
3,814
zyedidia/micro
13,805
Go
niten94
JoeKar
command := buffer.Command{ StartCursor: flagStartPos, SearchRegex: searchText, SearchAfterStart: searchIndex > posIndex, } btype := buffer.BTDefault if len(files) > 0 { // Option 1 // We go through each file and load it for i := 0; i < len(files); i++ { buf, err := buffer.NewBufferFromFi...
But setting it here unconditionally to `BTStdout` might not be intended in every use case too, right? We should set it to `BTStdout` only in case there are no files given AND the stdout is not a terminal, right? Then this should simplify to: ```diff diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index f3f3be...
SearchRegex: searchText, SearchAfterStart: searchIndex > posIndex, } if len(files) > 0 { // Option 1 // We go through each file and load it for i := 0; i < len(files); i++ { buf, err := buffer.NewBufferFromFileWithCommand(files[i], buffer.BTDefault, command) if err != nil { screen.TermMessag...
@@ -234,6 +231,7 @@ func LoadInput(args []string) []*buffer.Buffer { // Option 2 // The input is not a terminal, so something is being piped in // and we should read from stdin + btype = buffer.BTStdout
cmd/micro/micro.go
26
Go
1
refactor
2,283
51
51
false
Only set buffer type to stdout when no file args are passed
3,910
zyedidia/micro
13,805
Go
JoeKar
AndydeCleyre
} else if len(posMatch) == 3 && posMatch[2] == "" { line, err := strconv.Atoi(posMatch[1]) if err != nil { screen.TermMessage(err) continue } flagStartPos = buffer.Loc{0, line - 1} posIndex = i } else { searchMatch := searchFlagr.FindStringSubmatch(a) if len(searchMatch) == 2 { sear...
It makes sense to move it even further below? as follows: ```go --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -213,13 +213,11 @@ func LoadInput(args []string) []*buffer.Buffer { SearchAfterStart: searchIndex > posIndex, } - btype := buffer.BTDefault - if len(files) > 0 { // Option 1 ...
screen.TermMessage(err) continue } flagStartPos = buffer.Loc{0, line - 1} posIndex = i } else { searchMatch := searchFlagr.FindStringSubmatch(a) if len(searchMatch) == 2 { searchText = searchMatch[1] searchIndex = i } else { files = append(files, a) } } } command := buffe...
@@ -218,6 +213,8 @@ func LoadInput(args []string) []*buffer.Buffer { SearchAfterStart: searchIndex > posIndex, } + btype := buffer.BTDefault
cmd/micro/micro.go
26
Go
1
suggestion
1,001
51
51
false
Only set buffer type to stdout when no file args are passed
3,910
zyedidia/micro
13,805
Go
dmaluka
AndydeCleyre
// We go through each file and load it for i := 0; i < len(files); i++ { buf, err := buffer.NewBufferFromFileWithCommand(files[i], btype, command) if err != nil { screen.TermMessage(err) continue } // If the file didn't exist, input will be empty, and we'll open an empty buffer buffers = appe...
IMHO this refactoring only makes it slightly less readable, not more readable. I'd rather just make the following change (on top of the 1st commit): ```go --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -243,7 +243,7 @@ func LoadInput(args []string) []*buffer.Buffer { buffers = append(buffers, buffer.Ne...
continue } // If the file didn't exist, input will be empty, and we'll open an empty buffer buffers = append(buffers, buf) } } else { btype := buffer.BTDefault if !isatty.IsTerminal(os.Stdout.Fd()) { btype = buffer.BTStdout } if !isatty.IsTerminal(os.Stdin.Fd()) { // Option 2 // The in...
@@ -240,11 +240,9 @@ func LoadInput(args []string) []*buffer.Buffer { screen.TermMessage("Error reading from stdin: ", err) input = []byte{} } - buffers = append(buffers, buffer.NewBufferFromStringWithCommand(string(input), filename, btype, command)) - } else { - // Option 3, just open an empty buffe...
cmd/micro/micro.go
26
Go
1
refactor
738
51
51
false
Only set buffer type to stdout when no file args are passed
3,910
zyedidia/micro
13,805
Go
dmaluka
AndydeCleyre
// We go through each file and load it for i := 0; i < len(files); i++ { buf, err := buffer.NewBufferFromFileWithCommand(files[i], buffer.BTDefault, command) if err != nil { screen.TermMessage(err) continue } // If the file didn't exist, input will be empty, and we'll open an empty buffer buf...
We can now remove ```go var input []byte var err error ``` from line 162+163 too and replace `input, err = io.ReadAll(os.Stdin)` in line 238 with `input, err := io.ReadAll(os.Stdin)` The commit message doesn't fit any longer. I assume the change history needs a bit more polish now. @dmaluka: What do you th...
if err != nil { screen.TermMessage(err) continue } // If the file didn't exist, input will be empty, and we'll open an empty buffer buffers = append(buffers, buf) } } else { btype := buffer.BTDefault if !isatty.IsTerminal(os.Stdout.Fd()) { btype = buffer.BTStdout } if !isatty.IsTermin...
@@ -243,7 +243,7 @@ func LoadInput(args []string) []*buffer.Buffer { buffers = append(buffers, buffer.NewBufferFromStringWithCommand(string(input), filename, btype, command))
cmd/micro/micro.go
26
Go
1
suggestion
430
51
51
false
Only set buffer type to stdout when no file args are passed
3,910
zyedidia/micro
13,805
Go
JoeKar
AndydeCleyre
// FindNext finds the next occurrence of a given string in the buffer // It returns the start and end location of the match (if found) and // a boolean indicating if it was found // May also return an error if the search regex is invalid func (b *Buffer) FindNext(s string, start, end, from Loc, down bool, useRegex bool...
I like how it is proposed to simplify in #3913: ```go if b.Settings["ignorecase"].(bool) { s = "(?i)" + s } ``` Afterwards we can perform your introduced check with: ```go r, err = regexp.Compile("(" + s + ")") if err != nil { return [2]Loc{}, false, err } ``` The benefit is, that we should compile the strin...
} else if match[1] != end { loc = match[1].Move(1, b) } else { break } } return matches } // FindNext finds the next occurrence of a given string in the buffer // It returns the start and end location of the match (if found) and // a boolean indicating if it was found // May also return an error if the s...
@@ -160,6 +160,10 @@ func (b *Buffer) FindNext(s string, start, end, from Loc, down bool, useRegex bo r, err = regexp.Compile(s) } + if err == nil { + _, err = regexp.Compile("(" + s + ")") + } +
internal/buffer/search.go
26
Go
0.857
refactor
608
51
51
false
quick fix for #3700
3,914
zyedidia/micro
13,805
Go
JoeKar
matthias314
func findLineParams(b *Buffer, start, end Loc, i int, r *regexp.Regexp) ([]byte, int, int, *regexp.Regexp) { l := b.LineBytes(i) charpos := 0 padMode := 0 if i == end.Y { nchars := util.CharacterCount(l) end.X = util.Clamp(end.X, 0, nchars) if end.X < nchars { l = util.SliceStart(l, end.X+1) padMode |...
I think this approach is the best. I attempted to avoid other potential problems in my suggestions, but there seems to be none and I realized such would be too rare. Couldn't `\E` be added only when `padMode & (padStart|padEnd) != 0`, so that it's performed only when needed and not every line? Otherwise, the curr...
func findLineParams(b *Buffer, start, end Loc, i int, r *regexp.Regexp) ([]byte, int, int, *regexp.Regexp) { l := b.LineBytes(i) charpos := 0 padMode := 0 if i == end.Y { nchars := util.CharacterCount(l) end.X = util.Clamp(end.X, 0, nchars) if end.X < nchars { l = util.SliceStart(l, end.X+1) padMode |...
@@ -41,6 +41,12 @@ func findLineParams(b *Buffer, start, end Loc, i int, r *regexp.Regexp) ([]byte, } } + re, err := regexp.Compile(r.String() + `\E`)
internal/buffer/search.go
26
Go
0.643
suggestion
381
51
51
false
quick fix for #3700
3,914
zyedidia/micro
13,805
Go
niten94
matthias314
if s, ok := config.Colorscheme["selection"]; ok { style = s } } screen.SetContent(vlocX, i.Y, r, combc, style) vlocX += runewidth.RuneWidth(r) } nColsBeforeStart-- } totalwidth := blocX - nColsBeforeStart for len(line) > 0 { curVX := vlocX curBX := blocX r, combc, size := util.Deco...
We should start from 0, not from 1? (assuming that the overall approach of this PR is correct at all)
if s, ok := config.Colorscheme["selection"]; ok { style = s } } screen.SetContent(vlocX, i.Y, r, combc, style) vlocX += runewidth.RuneWidth(r) } nColsBeforeStart-- } totalwidth := blocX - nColsBeforeStart for len(line) > 0 { curVX := vlocX curBX := blocX r, combc, size := util.Deco...
@@ -146,25 +138,19 @@ func (i *InfoWindow) displayBuffer() { width := 0 - char := ' ' switch r { case '\t': - ts := tabsize - (totalwidth % tabsize) - width = ts + width = tabsize - (totalwidth % tabsize) + for j := 1; j < width; j++ {
internal/display/infowindow.go
26
Go
0.429
suggestion
101
51
51
false
fix drawing of wide characters in InfoWindow
3,919
zyedidia/micro
13,805
Go
dmaluka
Andriamanitra
copy(n.parent.children[ind:], successor.children) for i := 0; i < len(successor.children); i++ { n.parent.children[ind+i].parent = n.parent } } // Update propW and propH since the parent of the children has been updated, // so the children have new siblings n.parent.markSizes() } // String returns the s...
Maybe better? ``` marker := "/" if n.Kind == STVert { marker = "|" } else if n.Kind == STHoriz { marker = "-" } var str string parentId := 0 if n.parent != nil { parentId = n.parent.id } str = fmt.Sprint(strings.Repeat("\t", ident), marker, n.View, n.id, parentId) ```
successor.Kind = n.Kind } else { // If the successor node has children, that means it is a chained parent as well. // Therefore it can be replaced by its own children. origsize := len(n.parent.children) // Let's say we have 5 children and want to replace [2] with its children [a] [b] [c] // [0] [1] [2] [3...
@@ -535,7 +535,12 @@ func (n *Node) String() string { if n.Kind == STHoriz { marker = "-" } - str := fmt.Sprint(strings.Repeat("\t", ident), marker, n.View, n.id) + var str string + if n.parent != nil { + str = fmt.Sprint(strings.Repeat("\t", ident), marker, n.View, n.id, n.parent.id) + } else { + str...
internal/views/splits.go
26
Go
0.857
suggestion
283
38
51
false
Fixing missing case for handling root node for splitting
3,983
zyedidia/micro
13,805
Go
JoeKar
Neko-Box-Coder
ind := 0 for i, c := range n.parent.children { if c.id == n.id { ind = i } } n.parent.unsplit(ind) if n.parent.IsLeaf() { return n.parent.Unsplit() } n.parent.flatten() return true } // flattens the tree by removing unnecessary intermediate parents that have only one child // and handles the side eff...
Ah, yes...right. We overwrite the root node with the last remaining children, by which it receives the `id` of the children, with which it is identified in the tab resize. But still we should keep the removed `n.Kind = STUndef`, otherwise `func (n *Node) String()` wouldn't print what we expect from the new root. Other...
ind := 0 for i, c := range n.parent.children { if c.id == n.id { ind = i } } n.parent.unsplit(ind) if n.parent.IsLeaf() { return n.parent.Unsplit() } n.parent.flatten() return true } // flattens the tree by removing unnecessary intermediate parents that have only one child // and handles the side eff...
@@ -483,7 +483,14 @@ func (n *Node) Unsplit() bool { // flattens the tree by removing unnecessary intermediate parents that have only one child // and handles the side effect of it func (n *Node) flatten() { - if n.parent == nil || len(n.children) != 1 { + if len(n.children) != 1 { + return + } + + // Special case ...
internal/views/splits.go
26
Go
0.643
bug
720
51
51
false
Fixing missing case for handling root node for splitting
3,983
zyedidia/micro
13,805
Go
JoeKar
Neko-Box-Coder
} } // Update propW and propH since the parent of the children has been updated, // so the children have new siblings n.parent.markSizes() } // String returns the string form of the node and all children (used for debugging) func (n *Node) String() string { var strf func(n *Node, ident int) string strf = func...
I think we should slightly rework this: ```go var marker string var parentId uint64 = 0 if n.parent == nil { marker = "/" } else { if n.Kind == STHoriz { marker = "-" } else if n.Kind == STVert { marker = "|" } parentId = n.parent.id } ``` What do you think?
for i := 0; i < len(successor.children); i++ { n.parent.children[ind+i].parent = n.parent } } // Update propW and propH since the parent of the children has been updated, // so the children have new siblings n.parent.markSizes() } // String returns the string form of the node and all children (used for de...
@@ -531,11 +541,17 @@ func (n *Node) flatten() { func (n *Node) String() string { var strf func(n *Node, ident int) string strf = func(n *Node, ident int) string { - marker := "|" + marker := "/" if n.Kind == STHoriz { marker = "-" + } else if n.Kind == STVert { + marker = "|" + } + var parentId uint...
internal/views/splits.go
26
Go
0.857
question
292
35
40
false
Fixing missing case for handling root node for splitting
3,983
zyedidia/micro
13,805
Go
JoeKar
Neko-Box-Coder
messenger.Reset() v.Cursor.ResetSelection() } // HandleSearchEvent takes an event and a view and will do a real time match from the messenger's output // to the current buffer. It searches down the buffer. func HandleSearchEvent(event tcell.Event, v *View) { switch e := event.(type) { case *tcell.EventKey: switc...
No issues found.
messenger.Reset() v.Cursor.ResetSelection() } // HandleSearchEvent takes an event and a view and will do a real time match from the messenger's output // to the current buffer. It searches down the buffer. func HandleSearchEvent(event tcell.Event, v *View) { switch e := event.(type) { case *tcell.EventKey: switc...
@@ -21,10 +21,12 @@ var ( ) // BeginSearch starts a search -func BeginSearch() { +func BeginSearch(searchStr string) { searchHistory = append(searchHistory, "") messenger.historyNum = len(searchHistory) - 1 searching = true + messenger.response = searchStr + messenger.cursorx = Count(searchStr) messenger.ha...
cmd/micro/search.go
0
Go
1
none
16
51
51
true
Improve Search behaviour, and Escape key behaviour
409
zyedidia/micro
13,805
Go
ilius
v.Buf.clearCursors() } v.Buf.Redo() messenger.Message("Redid action") if usePlugin { return PostActionCall("Redo", v) } return true } // Copy the selection to the system clipboard func (v *View) Copy(usePlugin bool) bool { if v.mainCursor() { if usePlugin && !PreActionCall("Copy", v) { return false ...
No issues found.
v.Buf.clearCursors() } v.Buf.Redo() messenger.Message("Redid action") if usePlugin { return PostActionCall("Redo", v) } return true } // Copy the selection to the system clipboard func (v *View) Copy(usePlugin bool) bool { if v.mainCursor() { if usePlugin && !PreActionCall("Copy", v) { return false ...
@@ -1515,6 +1515,42 @@ func (v *View) PageDown(usePlugin bool) bool { return false } +// SelectPageUp selects up one page +func (v *View) SelectPageUp(usePlugin bool) bool { + if usePlugin && !PreActionCall("SelectPageUp", v) { + return false + } + + if !v.Cursor.HasSelection() { + v.Cursor.OrigSelection[0] = v....
cmd/micro/actions.go
0
Go
1
none
16
51
51
true
a few miscellaneous fixes and improvements
1,105
zyedidia/micro
13,805
Go
jtolio
func (w *BufWindow) getRowCount(line int) int { return w.getRow(buffer.Loc{X: util.CharacterCount(w.Buf.LineBytes(line)), Y: line}) + 1 } func (w *BufWindow) scrollUp(s SLoc, n int) SLoc { for n > 0 { if n <= s.Row { s.Row -= n n = 0 } else if s.Line > 0 { s.Line-- n -= s.Row + 1 s.Row = w.getRow...
No issues found.
func (w *BufWindow) getRowCount(line int) int { return w.getRow(buffer.Loc{X: util.CharacterCount(w.Buf.LineBytes(line)), Y: line}) + 1 } func (w *BufWindow) scrollUp(s SLoc, n int) SLoc { for n > 0 { if n <= s.Row { s.Row -= n n = 0 } else if s.Line > 0 { s.Line-- n -= s.Row + 1 s.Row = w.getRow...
@@ -0,0 +1,149 @@ +package display + +import ( + "github.com/zyedidia/micro/v2/internal/buffer" + "github.com/zyedidia/micro/v2/internal/util" +) + +// SLoc represents a vertical scrolling location, i.e. a location of a visual line +// in the buffer. When softwrap is enabled, a buffer line may be displayed as +// multi...
internal/display/softwrap.go
0
Go
1
none
16
51
51
true
Fix softwrap scrolling issues
1,981
zyedidia/micro
13,805
Go
dmaluka
if reload == "prompt" { InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool) { if canceled { h.Buf.DisableReload() } if !yes || canceled { h.Buf.UpdateModTime() } else { h.ReOpen() } }) } else if reload == "auto" { h.ReOpen() ...
No issues found.
if reload == "prompt" { InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool) { if canceled { h.Buf.DisableReload() } if !yes || canceled { h.Buf.UpdateModTime() } else { h.ReOpen() } }) } else if reload == "auto" { h.ReOpen() ...
@@ -746,10 +746,16 @@ var BufKeyActions = map[string]BufKeyAction{ "SelectRight": (*BufPane).SelectRight, "WordRight": (*BufPane).WordRight, "WordLeft": (*BufPane).WordLeft, + "SubWordRight": (*BufPane).SubWordRight, + "SubWordLeft": (*BufP...
internal/action/bufpane.go
0
Go
1
none
16
51
51
true
Implemented sub-word cursor movement
2,665
zyedidia/micro
13,805
Go
masmu
package config import ( "embed" "path/filepath" "strings" ) //go:generate go run syntax/make_headers.go syntax //go:embed colorschemes help plugins syntax var runtime embed.FS func fixPath(name string) string { return strings.TrimLeft(filepath.ToSlash(name), "runtime/") } // AssetDir lists file names in folder...
No issues found.
package config import ( "embed" "path/filepath" "strings" ) //go:generate go run syntax/make_headers.go syntax //go:embed colorschemes help plugins syntax var runtime embed.FS func fixPath(name string) string { return strings.TrimLeft(filepath.ToSlash(name), "runtime/") } // AssetDir lists file names in folder...
@@ -22,7 +22,7 @@ func AssetDir(name string) ([]string, error) { if err != nil { return nil, err } - names := make([]string, len(entries), len(entries)) + names := make([]string, len(entries)) for i, entry := range entries { names[i] = entry.Name() }
runtime/runtime.go
0
Go
1
none
16
37
37
true
refactor(runtime): simplify AssetDir()
2,761
zyedidia/micro
13,805
Go
mjholub
) type HeaderYaml struct { FileType string `yaml:"filetype"` Detect struct { FNameRgx string `yaml:"filename"` SignatureRgx string `yaml:"signature"` } `yaml:"detect"` } type Header struct { FileType string FNameRgx string SignatureRgx string } func main() { if len(os.Args) > 1 { os.Chdir(...
No issues found.
) type HeaderYaml struct { FileType string `yaml:"filetype"` Detect struct { FNameRgx string `yaml:"filename"` SignatureRgx string `yaml:"signature"` } `yaml:"detect"` } type Header struct { FileType string FNameRgx string SignatureRgx string } func main() { if len(os.Args) > 1 { os.Chdir(...
@@ -1,4 +1,5 @@ -//+build ignore +//go:build ignore +// +build ignore package main @@ -16,15 +17,15 @@ import ( type HeaderYaml struct { FileType string `yaml:"filetype"` Detect struct { - FNameRgx string `yaml:"filename"` - HeaderRgx string `yaml:"header"` + FNameRgx string `yaml:"filename"` + Sig...
runtime/syntax/make_headers.go
0
Go
1
none
16
51
51
true
Improve file detection with signature check capabilities
2,819
zyedidia/micro
13,805
Go
JoeKar
} if err != nil { reterr = errors.New("Plugin " + p.Name + ": " + err.Error()) continue } if v, ok := val.(lua.LBool); ok { retbool = retbool && bool(v) } } return retbool, reterr } // Plugin stores information about the source files/info for a plugin type Plugin struct { DirName string //...
No issues found.
} if err != nil { reterr = errors.New("Plugin " + p.Name + ": " + err.Error()) continue } if v, ok := val.(lua.LBool); ok { retbool = retbool && bool(v) } } return retbool, reterr } // Plugin stores information about the source files/info for a plugin type Plugin struct { DirName string //...
@@ -28,7 +28,7 @@ func LoadAllPlugins() error { func RunPluginFn(fn string, args ...lua.LValue) error { var reterr error for _, p := range Plugins { - if !p.IsEnabled() { + if !p.IsLoaded() { continue } _, err := p.Call(fn, args...) @@ -42,11 +42,11 @@ func RunPluginFn(fn string, args ...lua.LValue) er...
internal/config/plugin.go
0
Go
1
none
16
51
51
true
plugins: Add capability to dis-/enable them per buffer
2,836
zyedidia/micro
13,805
Go
JoeKar
fg, bg, _ := s.Decompose() assert.Equal(t, tcell.ColorBlue, fg) assert.Equal(t, tcell.ColorPurple, bg) } func TestAttributeStringToStyle(t *testing.T) { s := StringToStyle("bold cyan,brightcyan") fg, bg, attr := s.Decompose() assert.Equal(t, tcell.ColorTeal, fg) assert.Equal(t, tcell.ColorAqua, bg) assert.N...
No issues found.
fg, bg, _ := s.Decompose() assert.Equal(t, tcell.ColorBlue, fg) assert.Equal(t, tcell.ColorPurple, bg) } func TestAttributeStringToStyle(t *testing.T) { s := StringToStyle("bold cyan,brightcyan") fg, bg, attr := s.Decompose() assert.Equal(t, tcell.ColorTeal, fg) assert.Equal(t, tcell.ColorAqua, bg) assert.N...
@@ -65,7 +65,7 @@ color-link constant "#AE81FF,#282828" color-link constant.string "#E6DB74,#282828" color-link constant.string.char "#BDE6AD,#282828"` - c, err := ParseColorscheme(testColorscheme) + c, err := ParseColorscheme("testColorscheme", testColorscheme, nil) assert.Nil(t, err) fg, bg, _ := c["comment...
internal/config/colorscheme_test.go
0
Go
1
none
16
51
51
true
colorscheme: Add capability to include schemes
2,844
zyedidia/micro
13,805
Go
JoeKar
var interfaceArr []interface{} valType := reflect.TypeOf(value) defType := reflect.TypeOf(def) assignable := false switch option { case "pluginrepos", "pluginchannels": assignable = valType.AssignableTo(reflect.TypeOf(interfaceArr)) default: assignable = defType.AssignableTo(valType) } if !assignable { ...
No issues found.
var interfaceArr []interface{} valType := reflect.TypeOf(value) defType := reflect.TypeOf(def) assignable := false switch option { case "pluginrepos", "pluginchannels": assignable = valType.AssignableTo(reflect.TypeOf(interfaceArr)) default: assignable = defType.AssignableTo(valType) } if !assignable { ...
@@ -36,6 +36,7 @@ var optionValidators = map[string]optionValidator{ "scrollmargin": validateNonNegativeValue, "scrollspeed": validateNonNegativeValue, "tabsize": validatePositiveValue, + "truecolor": validateChoice, } // a list of settings with pre-defined choices @@ -46,6 +47,7 @@ var O...
internal/config/settings.go
0
Go
1
none
16
51
51
true
options: Add `truecolor` to control the mode
2,867
zyedidia/micro
13,805
Go
JoeKar
l := b.LineBytes(c.Y) l = util.SliceStart(l, c.X) input, argstart := b.GetArg() completeValue := false args := bytes.Split(l, []byte{' '}) if len(args) >= 2 { // localSettings := config.DefaultLocalSettings() for option := range config.GlobalSettings { if option == string(args[len(args)-2]) { complete...
No issues found.
l := b.LineBytes(c.Y) l = util.SliceStart(l, c.X) input, argstart := b.GetArg() completeValue := false args := bytes.Split(l, []byte{' '}) if len(args) >= 2 { // localSettings := config.DefaultLocalSettings() for option := range config.GlobalSettings { if option == string(args[len(args)-2]) { complete...
@@ -216,6 +216,13 @@ func OptionValueComplete(b *buffer.Buffer) ([]string, []string) { if strings.HasPrefix("terminal", input) { suggestions = append(suggestions, "terminal") } + case "matchbracestyle": + if strings.HasPrefix("underline", input) { + suggestions = append(suggestions, "underline") + ...
internal/action/infocomplete.go
0
Go
1
none
16
51
51
true
options: add `matchbracestyle`
2,876
zyedidia/micro
13,805
Go
toiletbril
} else { h.GotoLoc(h.searchOrig) h.Cursor.ResetSelection() } } } findCallback := func(resp string, canceled bool) { // Finished callback if !canceled { match, found, err := h.Buf.FindNext(resp, h.Buf.Start(), h.Buf.End(), h.searchOrig, true, useRegex) if err != nil { InfoBar.Error(err) ...
No issues found.
} else { h.GotoLoc(h.searchOrig) h.Cursor.ResetSelection() } } } findCallback := func(resp string, canceled bool) { // Finished callback if !canceled { match, found, err := h.Buf.FindNext(resp, h.Buf.Start(), h.Buf.End(), h.searchOrig, true, useRegex) if err != nil { InfoBar.Error(err) ...
@@ -1582,9 +1582,7 @@ func (h *BufPane) QuitAll() bool { } quit := func() { - for _, b := range buffer.OpenBuffers { - b.Close() - } + buffer.CloseOpenBuffers() screen.Screen.Fini() InfoBar.Close() runtime.Goexit()
internal/action/actions.go
0
Go
1
none
16
51
51
true
actions: Fix the iteration over a slice under modification in QuitAll()
2,898
zyedidia/micro
13,805
Go
JoeKar
} func findBuffer(file string) *buffer.Buffer { var buf *buffer.Buffer for _, b := range buffer.OpenBuffers { if b.Path == file { buf = b } } return buf } func createTestFile(name string, content string) (string, error) { testf, err := ioutil.TempFile("", name) if err != nil { return "", err } if _,...
No issues found.
} func findBuffer(file string) *buffer.Buffer { var buf *buffer.Buffer for _, b := range buffer.OpenBuffers { if b.Path == file { buf = b } } return buf } func createTestFile(name string, content string) (string, error) { testf, err := ioutil.TempFile("", name) if err != nil { return "", err } if _,...
@@ -109,7 +109,10 @@ func handleEvent() { if e != nil { screen.Events <- e } - DoEvent() + + for len(screen.DrawChan()) > 0 || len(screen.Events) > 0 { + DoEvent() + } } func injectKey(key tcell.Key, r rune, mod tcell.ModMask) { @@ -151,6 +154,16 @@ func openFile(file string) { injectKey(tcell.KeyEnter, r...
cmd/micro/micro_test.go
0
Go
1
none
16
51
51
true
syntax: Provide default.yaml as fallback definition
2,933
zyedidia/micro
13,805
Go
JoeKar
completions[i] = util.SliceEndStr(suggestions[i], c.X-argstart) } return completions, suggestions } // OptionValueComplete completes values for various options func OptionValueComplete(b *buffer.Buffer) ([]string, []string) { c := b.GetActiveCursor() l := b.LineBytes(c.Y) l = util.SliceStart(l, c.X) input, arg...
No issues found.
completions[i] = util.SliceEndStr(suggestions[i], c.X-argstart) } return completions, suggestions } // OptionValueComplete completes values for various options func OptionValueComplete(b *buffer.Buffer) ([]string, []string) { c := b.GetActiveCursor() l := b.LineBytes(c.Y) l = util.SliceStart(l, c.X) input, arg...
@@ -192,36 +192,20 @@ func OptionValueComplete(b *buffer.Buffer) ([]string, []string) { _, suggestions = colorschemeComplete(input) case "filetype": _, suggestions = filetypeComplete(input) - case "fileformat": - if strings.HasPrefix("unix", input) { - suggestions = append(suggestions, "unix") - } - ...
internal/action/infocomplete.go
0
Go
1
none
16
51
51
true
Reduce the available string option validators and add autocompletion for them
3,021
zyedidia/micro
13,805
Go
JoeKar
} buffers = append(buffers, buffer.NewBufferFromStringAtLoc(string(input), filename, btype, flagStartPos)) } else { // Option 3, just open an empty buffer buffers = append(buffers, buffer.NewBufferFromStringAtLoc(string(input), filename, btype, flagStartPos)) } return buffers } func main() { defer func() ...
No issues found.
} buffers = append(buffers, buffer.NewBufferFromStringAtLoc(string(input), filename, btype, flagStartPos)) } else { // Option 3, just open an empty buffer buffers = append(buffers, buffer.NewBufferFromStringAtLoc(string(input), filename, btype, flagStartPos)) } return buffers } func main() { defer func() ...
@@ -255,6 +255,8 @@ func main() { } config.InitRuntimeFiles() + config.InitPlugins() + err = config.ReadSettings() if err != nil { screen.TermMessage(err)
cmd/micro/micro.go
0
Go
1
none
16
51
51
true
command: Fix `reload` command to correctly initialize and reload all runtime files
3,062
zyedidia/micro
13,805
Go
JoeKar
for i := 0; i < testingB.N; i++ { b.Bytes() for j := 0; j < b.LinesNum(); j++ { b.Line(j) b.LineBytes(j) } } testingB.StopTimer() b.Close() } func benchEdit(testingB *testing.B, nLines, nCursors int) { rand.Seed(int64(nLines + nCursors)) b := NewBufferFromString(randomText(nLines), "", BTDefault)...
No issues found.
for i := 0; i < testingB.N; i++ { b.Bytes() for j := 0; j < b.LinesNum(); j++ { b.Line(j) b.LineBytes(j) } } testingB.StopTimer() b.Close() } func benchEdit(testingB *testing.B, nLines, nCursors int) { rand.Seed(int64(nLines + nCursors)) b := NewBufferFromString(randomText(nLines), "", BTDefault)...
@@ -20,9 +20,7 @@ type operation struct { func init() { ulua.L = lua.NewState() - // TODO: uncomment InitRuntimeFiles once we fix races between syntax - // highlighting and buffer editing. - // config.InitRuntimeFiles(false) + config.InitRuntimeFiles(false) config.InitGlobalSettings() config.GlobalSettings["ba...
internal/buffer/buffer_test.go
0
Go
1
none
16
51
51
true
buffer: Add proper lock mechanism to lock the full `LineArray` instead of single lines
3,224
zyedidia/micro
13,805
Go
JoeKar
func (t *TermPane) Close() {} // Quit closes this termpane func (t *TermPane) Quit() { t.Close() if len(MainTab().Panes) > 1 { t.Unsplit() } else if len(Tabs.List) > 1 { Tabs.RemoveTab(t.id) } else { screen.Screen.Fini() InfoBar.Close() runtime.Goexit() } } // Unsplit removes this split func (t *TermP...
No issues found.
func (t *TermPane) Close() {} // Quit closes this termpane func (t *TermPane) Quit() { t.Close() if len(MainTab().Panes) > 1 { t.Unsplit() } else if len(Tabs.List) > 1 { Tabs.RemoveTab(t.id) } else { screen.Screen.Fini() InfoBar.Close() runtime.Goexit() } } // Unsplit removes this split func (t *TermP...
@@ -81,6 +81,10 @@ func (t *TermPane) SetID(i uint64) { t.id = i } +func (t *TermPane) Name() string { + return t.Terminal.Name() +} + func (t *TermPane) SetTab(tab *Tab) { t.tab = tab }
internal/action/termpane.go
0
Go
1
none
16
51
51
true
action: Stop processing chained actions/commands in the moment the current `Pane` is not a `BufPane` (fix crash)
3,261
zyedidia/micro
13,805
Go
JoeKar
} // HandleEvent executes the tcell event properly func (h *BufPane) HandleEvent(event tcell.Event) { if h.Buf.ExternallyModified() && !h.Buf.ReloadDisabled { reload := h.getReloadSetting() if reload == "prompt" { InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool...
No issues found.
} // HandleEvent executes the tcell event properly func (h *BufPane) HandleEvent(event tcell.Event) { if h.Buf.ExternallyModified() && !h.Buf.ReloadDisabled { reload := h.getReloadSetting() if reload == "prompt" { InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool...
@@ -500,12 +500,17 @@ func (h *BufPane) HandleEvent(event tcell.Event) { // Mouse event with no click - mouse was just released. // If there were multiple mouse buttons pressed, we don't know which one // was actually released, so we assume they all were released. + pressed := len(h.mousePressed) > 0 ...
internal/action/bufpane.go
0
Go
1
none
16
51
51
true
Fix lost mouse release events in case the pane becomes inactive
3,271
zyedidia/micro
13,805
Go
JoeKar
h.Buf.HighlightSearch = h.Buf.Settings["hlsearch"].(bool) } else { h.Cursor.ResetSelection() } return nil } func (h *BufPane) find(useRegex bool) bool { h.searchOrig = h.Cursor.Loc prompt := "Find: " if useRegex { prompt = "Find (regex): " } var eventCallback func(resp string) if h.Buf.Settings["incsear...
No issues found.
h.Buf.HighlightSearch = h.Buf.Settings["hlsearch"].(bool) } else { h.Cursor.ResetSelection() } return nil } func (h *BufPane) find(useRegex bool) bool { h.searchOrig = h.Cursor.Loc prompt := "Find: " if useRegex { prompt = "Find (regex): " } var eventCallback func(resp string) if h.Buf.Settings["incsear...
@@ -1072,8 +1072,20 @@ func (h *BufPane) UnhighlightSearch() bool { return true } +// ResetSearch resets the last used search term +func (h *BufPane) ResetSearch() bool { + if h.Buf.LastSearch != "" { + h.Buf.LastSearch = "" + return true + } + return false +} + // FindNext searches forwards for the last used s...
internal/action/actions.go
0
Go
1
none
16
51
51
true
Implemented `ResetSearch` and allow action chaining of `FindNext` and `FindPrevious`
3,333
zyedidia/micro
13,805
Go
masmu
"Delete": "Delete", "Ctrl-b": "ShellMode", "Ctrl-q": "Quit", "Ctrl-e": "CommandMode", "Ctrl-w": "NextSplit", "Ctrl-u": "ToggleMacro", "Ctrl-j": "PlayMacro", "Insert": "ToggleOverwriteMode", // Emacs-style keybindings "Alt-f": "WordRight", "Alt-...
No issues found.
"Delete": "Delete", "Ctrl-b": "ShellMode", "Ctrl-q": "Quit", "Ctrl-e": "CommandMode", "Ctrl-w": "NextSplit", "Ctrl-u": "ToggleMacro", "Ctrl-j": "PlayMacro", "Insert": "ToggleOverwriteMode", // Emacs-style keybindings "Alt-f": "WordRight", "Alt-...
@@ -45,10 +45,10 @@ var bufdefaults = map[string]string{ "Alt-]": "DiffNext|CursorEnd", "Ctrl-z": "Undo", "Ctrl-y": "Redo", - "Ctrl-c": "CopyLine|Copy", - "Ctrl-x": "Cut", + "Ctrl-c": "Copy|CopyLine", + "Ctrl-x": "Cut|CutLine", "Ctrl-k": "CutLine"...
internal/action/defaults_darwin.go
0
Go
1
none
16
51
51
true
Improve and unify `CopyLine`, `CutLine`, `DeleteLine`, `DuplicateLine` actions
3,335
zyedidia/micro
13,805
Go
dmaluka
return true end return false end function commentLine(bp, lineN, indentLen) updateCommentType(bp.Buf) local line = bp.Buf:Line(lineN) local commentType = bp.Buf.Settings["commenttype"] local sel = -bp.Cursor.CurSelection local curpos = -bp.Cursor.Loc local index = string.find(c...
No issues found.
return true end return false end function commentLine(bp, lineN, indentLen) updateCommentType(bp.Buf) local line = bp.Buf:Line(lineN) local commentType = bp.Buf.Settings["commenttype"] local sel = -bp.Cursor.CurSelection local curpos = -bp.Cursor.Loc local index = string.find(c...
@@ -66,9 +66,9 @@ local last_ft function updateCommentType(buf) if buf.Settings["commenttype"] == nil or (last_ft ~= buf.Settings["filetype"] and last_ft ~= nil) then if ft[buf.Settings["filetype"]] ~= nil then - buf.Settings["commenttype"] = ft[buf.Settings["filetype"]] + buf:SetOp...
runtime/plugins/comment/comment.lua
0
Lua
1
none
16
51
51
true
Rework `filetype` change, `reload` command and `autosave`
3,343
zyedidia/micro
13,805
Go
JoeKar
h.Cursor.OrigSelection[0] = h.Cursor.CurSelection[0] h.Cursor.OrigSelection[1] = h.Cursor.CurSelection[1] h.GotoLoc(match[1]) } else { h.GotoLoc(h.searchOrig) h.Cursor.ResetSelection() } } } findCallback := func(resp string, canceled bool) { // Finished callback if !canceled { match...
No issues found.
h.Cursor.OrigSelection[0] = h.Cursor.CurSelection[0] h.Cursor.OrigSelection[1] = h.Cursor.CurSelection[1] h.GotoLoc(match[1]) } else { h.GotoLoc(h.searchOrig) h.Cursor.ResetSelection() } } } findCallback := func(resp string, canceled bool) { // Finished callback if !canceled { match...
@@ -1068,6 +1068,9 @@ func (h *BufPane) ToggleHighlightSearch() bool { // UnhighlightSearch unhighlights all instances of the last used search term func (h *BufPane) UnhighlightSearch() bool { + if !h.Buf.HighlightSearch { + return false + } h.Buf.HighlightSearch = false return true } @@ -1163,15 +1166,19 @@ ...
internal/action/actions.go
0
Go
1
none
16
51
51
true
Improve return values of some actions + some improvements
3,352
zyedidia/micro
13,805
Go
dmaluka
reload := h.getReloadSetting() if reload == "prompt" { InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool) { if canceled { h.Buf.DisableReload() } if !yes || canceled { h.Buf.UpdateModTime() } else { h.ReOpen() } }) } else if ...
No issues found.
reload := h.getReloadSetting() if reload == "prompt" { InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool) { if canceled { h.Buf.DisableReload() } if !yes || canceled { h.Buf.UpdateModTime() } else { h.ReOpen() } }) } else if ...
@@ -759,6 +759,8 @@ var BufKeyActions = map[string]BufKeyAction{ "SelectToEndOfLine": (*BufPane).SelectToEndOfLine, "ParagraphPrevious": (*BufPane).ParagraphPrevious, "ParagraphNext": (*BufPane).ParagraphNext, + "SelectToParagraphPrevious": (*BufPane).SelectToParagraphPrevious, + "Sele...
internal/action/bufpane.go
0
Go
1
none
16
51
51
true
Adding selection for ParagraphPrevious and ParagraphNext.
3,353
zyedidia/micro
13,805
Go
hchac
buffers = append(buffers, buffer.NewBufferFromStringAtLoc(string(input), filename, btype, flagStartPos)) } return buffers } func main() { defer func() { if util.Stdout.Len() > 0 { fmt.Fprint(os.Stdout, util.Stdout.String()) } os.Exit(0) }() var err error InitFlags() if *flagProfile { f, err := ...
No issues found.
buffers = append(buffers, buffer.NewBufferFromStringAtLoc(string(input), filename, btype, flagStartPos)) } return buffers } func main() { defer func() { if util.Stdout.Len() > 0 { fmt.Fprint(os.Stdout, util.Stdout.String()) } os.Exit(0) }() var err error InitFlags() if *flagProfile { f, err := ...
@@ -40,8 +40,7 @@ var ( flagClean = flag.Bool("clean", false, "Clean configuration directory") optionFlags map[string]*string - sigterm chan os.Signal - sighup chan os.Signal + sighup chan os.Signal timerChan chan func() ) @@ -360,9 +359,9 @@ func main() { screen.Events = make(chan tcell.Event) ...
cmd/micro/micro.go
0
Go
1
none
16
51
51
true
Receive SIGINT only in RunInteractiveShell
3,357
zyedidia/micro
13,805
Go
niten94
if canceled { h.Buf.DisableReload() } if !yes || canceled { h.Buf.UpdateModTime() } else { h.ReOpen() } }) } else if reload == "auto" { h.ReOpen() } else if reload == "disabled" { h.Buf.DisableReload() } else { InfoBar.Message("Invalid reload setting") } } switc...
No issues found.
if canceled { h.Buf.DisableReload() } if !yes || canceled { h.Buf.UpdateModTime() } else { h.ReOpen() } }) } else if reload == "auto" { h.ReOpen() } else if reload == "disabled" { h.Buf.DisableReload() } else { InfoBar.Message("Invalid reload setting") } } switc...
@@ -663,19 +663,27 @@ func (h *BufPane) DoRuneInsert(r rune) { func (h *BufPane) VSplitIndex(buf *buffer.Buffer, right bool) *BufPane { e := NewBufPaneFromBuf(buf, h.tab) e.splitID = MainTab().GetNode(h.splitID).VSplit(right) - MainTab().Panes = append(MainTab().Panes, e) + currentPaneIdx := MainTab().GetPane(h.sp...
internal/action/bufpane.go
0
Go
1
none
16
51
51
true
Implemented new actions `FirstTab`, `LastTab`, `FirstSplit` and `LastSplit`
3,403
zyedidia/micro
13,805
Go
masmu
func (h *BufPane) HandleEvent(event tcell.Event) { if h.Buf.ExternallyModified() && !h.Buf.ReloadDisabled { reload := h.getReloadSetting() if reload == "prompt" { InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool) { if canceled { h.Buf.DisableReload() ...
No issues found.
func (h *BufPane) HandleEvent(event tcell.Event) { if h.Buf.ExternallyModified() && !h.Buf.ReloadDisabled { reload := h.getReloadSetting() if reload == "prompt" { InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool) { if canceled { h.Buf.DisableReload() ...
@@ -841,6 +841,7 @@ var BufKeyActions = map[string]BufKeyAction{ "RemoveMultiCursor": (*BufPane).RemoveMultiCursor, "RemoveAllMultiCursors": (*BufPane).RemoveAllMultiCursors, "SkipMultiCursor": (*BufPane).SkipMultiCursor, + "SkipMultiCursorBack": (*BufPane).SkipMultiCursorBack, "Jump...
internal/action/bufpane.go
0
Go
1
none
16
51
51
true
Implemented `SkipMultiCursorBack` as a counterpart to `SkipMultiCursor`
3,404
zyedidia/micro
13,805
Go
masmu
function startswith(str, start) return string.sub(str,1,string.len(start))==start end function endswith(str, endStr) return endStr=='' or string.sub(str,-string.len(endStr))==endStr end function split(string, sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) str...
No issues found.
function startswith(str, start) return string.sub(str,1,string.len(start))==start end function endswith(str, endStr) return endStr=='' or string.sub(str,-string.len(endStr))==endStr end function split(string, sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) str...
@@ -47,7 +47,6 @@ function onBufferOpen(buf) syntaxFile = syntaxFile .. " - special:\n" syntaxFile = syntaxFile .. " start: \"@\\\\{\"\n" syntaxFile = syntaxFile .. " end: \"\\\\}\"\n" - syntaxFile = syntaxFile .. " rules: []\n" syntaxFile =...
runtime/plugins/literate/literate.lua
0
Lua
1
none
16
51
51
true
Remove empty rules in regions
3,458
zyedidia/micro
13,805
Go
JoeKar
loc := endLoc if loc != nil { if !statesOnly { highlights[start+loc[0]] = curRegion.limitGroup } if curRegion.parent == nil { if !statesOnly { highlights[start+loc[1]] = 0 } h.highlightEmptyRegion(highlights, start+loc[1], canMatchEnd, lineNum, sliceStart(line, loc[1]), statesOnly) return hi...
No issues found.
loc := endLoc if loc != nil { if !statesOnly { highlights[start+loc[0]] = curRegion.limitGroup } if curRegion.parent == nil { if !statesOnly { highlights[start+loc[1]] = 0 } h.highlightEmptyRegion(highlights, start+loc[1], canMatchEnd, lineNum, sliceStart(line, loc[1]), statesOnly) return hi...
@@ -51,19 +51,6 @@ func runePos(p int, str []byte) int { return CharacterCount(str[:p]) } -func combineLineMatch(src, dst LineMatch) LineMatch { - for k, v := range src { - if g, ok := dst[k]; ok { - if g == 0 { - dst[k] = v - } - } else { - dst[k] = v - } - } - return dst -} - // A State represents t...
pkg/highlight/highlighter.go
0
Go
1
none
16
51
51
true
Remove unused internal or unexported functions
3,481
zyedidia/micro
13,805
Go
alexandear
} } pattern := string(h.Cursor.GetSelection()) if useRegex && pattern != "" { pattern = regexp.QuoteMeta(pattern) } if eventCallback != nil && pattern != "" { eventCallback(pattern) } InfoBar.Prompt(prompt, pattern, "Find", eventCallback, findCallback) if pattern != "" { InfoBar.SelectAll() } return t...
No issues found.
} } pattern := string(h.Cursor.GetSelection()) if useRegex && pattern != "" { pattern = regexp.QuoteMeta(pattern) } if eventCallback != nil && pattern != "" { eventCallback(pattern) } InfoBar.Prompt(prompt, pattern, "Find", eventCallback, findCallback) if pattern != "" { InfoBar.SelectAll() } return t...
@@ -1723,7 +1723,8 @@ func (h *BufPane) ToggleHelp() bool { if h.Buf.Type == buffer.BTHelp { h.Quit() } else { - h.openHelp("help") + hsplit := config.GlobalSettings["helpsplit"] == "hsplit" + h.openHelp("help", hsplit, false) } return true }
internal/action/actions.go
0
Go
1
none
16
51
51
true
action/command: Allow `-vsplit` & `-hsplit` as optional argument for `help`
3,502
zyedidia/micro
13,805
Go
JoeKar
} func verifySetting(option string, value interface{}, def interface{}) error { var interfaceArr []interface{} valType := reflect.TypeOf(value) defType := reflect.TypeOf(def) assignable := false switch option { case "pluginrepos", "pluginchannels": assignable = valType.AssignableTo(reflect.TypeOf(interfaceArr...
No issues found.
} func verifySetting(option string, value interface{}, def interface{}) error { var interfaceArr []interface{} valType := reflect.TypeOf(value) defType := reflect.TypeOf(def) assignable := false switch option { case "pluginrepos", "pluginchannels": assignable = valType.AssignableTo(reflect.TypeOf(interfaceArr...
@@ -32,6 +32,7 @@ var optionValidators = map[string]optionValidator{ "helpsplit": validateChoice, "matchbracestyle": validateChoice, "multiopen": validateChoice, + "pageoverlap": validateNonNegativeValue, "reload": validateChoice, "scrollmargin": validateNonNegativeValue, "scroll...
internal/config/settings.go
0
Go
1
none
16
51
51
true
implement nano-like page up/page down functionality
3,518
zyedidia/micro
13,805
Go
nimishjha
} var matchingBraces []buffer.Loc // bracePairs is defined in buffer.go if b.Settings["matchbrace"].(bool) { for _, c := range b.GetCursors() { if c.HasSelection() { continue } mb, left, found := b.FindMatchingBrace(c.Loc) if found { matchingBraces = append(matchingBraces, mb) if !left {...
No issues found.
} var matchingBraces []buffer.Loc // bracePairs is defined in buffer.go if b.Settings["matchbrace"].(bool) { for _, c := range b.GetCursors() { if c.HasSelection() { continue } mb, left, found := b.FindMatchingBrace(c.Loc) if found { matchingBraces = append(matchingBraces, mb) if !left {...
@@ -449,7 +449,7 @@ func (w *BufWindow) displayBuffer() { currentLine := false for _, c := range cursors { - if bloc.Y == c.Y && w.active { + if !c.HasSelection() && bloc.Y == c.Y && w.active { currentLine = true break }
internal/display/bufwindow.go
0
Go
1
none
16
51
51
true
actions: Perform `Cursor(Page)Down` with selection like GUI editors do
3,540
zyedidia/micro
13,805
Go
JoeKar
return end } else if l.LessThan(start) { return start } return l } // The following functions require a buffer to know where newlines are // Diff returns the distance between two locations func DiffLA(a, b Loc, buf *LineArray) int { if a.Y == b.Y { if a.X > b.X { return a.X - b.X } return b.X - a.X ...
No issues found.
return end } else if l.LessThan(start) { return start } return l } // The following functions require a buffer to know where newlines are // Diff returns the distance between two locations func DiffLA(a, b Loc, buf *LineArray) int { if a.Y == b.Y { if a.X > b.X { return a.X - b.X } return b.X - a.X ...
@@ -47,6 +47,16 @@ func (l Loc) LessEqual(b Loc) bool { return l == b } +// Clamp clamps a loc between start and end +func (l Loc) Clamp(start, end Loc) Loc { + if l.GreaterEqual(end) { + return end + } else if l.LessThan(start) { + return start + } + return l +} + // The following functions require a buffer to...
internal/buffer/loc.go
0
Go
1
none
16
51
51
true
match beginning and end of line correctly
3,575
zyedidia/micro
13,805
Go
matthias314
} else { h.ReOpen() } }) } else if reload == "auto" { h.ReOpen() } else if reload == "disabled" { h.Buf.DisableReload() } else { InfoBar.Message("Invalid reload setting") } } switch e := event.(type) { case *tcell.EventRaw: re := RawEvent{ esc: e.EscSeq(), } h.DoKeyEvent(re...
No issues found.
} else { h.ReOpen() } }) } else if reload == "auto" { h.ReOpen() } else if reload == "disabled" { h.Buf.DisableReload() } else { InfoBar.Message("Invalid reload setting") } } switch e := event.(type) { case *tcell.EventRaw: re := RawEvent{ esc: e.EscSeq(), } h.DoKeyEvent(re...
@@ -100,9 +100,7 @@ func BufMapEvent(k Event, action string) { break } - // TODO: fix problem when complex bindings have these - // characters (escape them?) - idx := strings.IndexAny(action, "&|,") + idx := util.IndexAnyUnquoted(action, "&|,") a := action if idx >= 0 { a = action[:idx]
internal/action/bufpane.go
0
Go
1
none
16
51
51
true
ignore quoted characters when splitting keybindings into actions
3,612
zyedidia/micro
13,805
Go
matthias314
b.UpdateRules() } } else if option == "infobar" || option == "keymenu" { Tabs.Resize() } else if option == "mouse" { if !nativeValue.(bool) { screen.Screen.DisableMouse() } else { screen.Screen.EnableMouse() } } else if option == "autosave" { if nativeValue.(float64) > 0 { config.SetAutoTime(...
No issues found.
b.UpdateRules() } } else if option == "infobar" || option == "keymenu" { Tabs.Resize() } else if option == "mouse" { if !nativeValue.(bool) { screen.Screen.DisableMouse() } else { screen.Screen.EnableMouse() } } else if option == "autosave" { if nativeValue.(float64) > 0 { config.SetAutoTime(...
@@ -630,7 +630,7 @@ func doSetGlobalOptionNative(option string, nativeValue any) error { return nil } -func SetGlobalOptionNative(option string, nativeValue any) error { +func SetGlobalOptionNative(option string, nativeValue any, writeToFile bool) error { if err := config.OptionIsValid(option, nativeValue); err ...
internal/action/command.go
0
Go
1
none
16
51
51
true
Removing the ability for plugins to modify settings.json and bindings.json. Adding an option to reject plugins to bind keys.
3,618
zyedidia/micro
13,805
Go
Neko-Box-Coder