mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 22:50:21 +09:00
@@ -1623,21 +1623,38 @@ func (v *View) JumpLine(usePlugin bool) bool {
|
||||
}
|
||||
|
||||
// Prompt for line number
|
||||
message := fmt.Sprintf("Jump to line (1 - %v) # ", v.Buf.NumLines)
|
||||
linestring, canceled := messenger.Prompt(message, "", "LineNumber", NoCompletion)
|
||||
message := fmt.Sprintf("Jump to line:col (1 - %v) # ", v.Buf.NumLines)
|
||||
input, canceled := messenger.Prompt(message, "", "LineNumber", NoCompletion)
|
||||
if canceled {
|
||||
return false
|
||||
}
|
||||
lineint, err := strconv.Atoi(linestring)
|
||||
lineint = lineint - 1 // fix offset
|
||||
if err != nil {
|
||||
messenger.Error(err) // return errors
|
||||
return false
|
||||
var lineInt int
|
||||
var colInt int
|
||||
var err error
|
||||
if strings.Contains(input, ":") {
|
||||
split := strings.Split(input, ":")
|
||||
lineInt, err = strconv.Atoi(split[0])
|
||||
if err != nil {
|
||||
messenger.Message("Invalid line number")
|
||||
return false
|
||||
}
|
||||
colInt, err = strconv.Atoi(split[1])
|
||||
if err != nil {
|
||||
messenger.Message("Invalid column number")
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
lineInt, err = strconv.Atoi(input)
|
||||
if err != nil {
|
||||
messenger.Message("Invalid line number")
|
||||
return false
|
||||
}
|
||||
}
|
||||
lineInt--
|
||||
// Move cursor and view if possible.
|
||||
if lineint < v.Buf.NumLines && lineint >= 0 {
|
||||
v.Cursor.X = 0
|
||||
v.Cursor.Y = lineint
|
||||
if lineInt < v.Buf.NumLines && lineInt >= 0 {
|
||||
v.Cursor.X = colInt
|
||||
v.Cursor.Y = lineInt
|
||||
|
||||
if usePlugin {
|
||||
return PostActionCall("JumpLine", v)
|
||||
|
||||
Reference in New Issue
Block a user