mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-24 17:50:15 +09:00
allow optionally brace matching with the closing brace to the left of the cursor
this behavior, while slightly less obvious, allows for observing what brace you just closed. as you write closing braces, the brace you closed gets highlighted
This commit is contained in:
@@ -73,9 +73,20 @@ func (c *CellView) Draw(buf *Buffer, top, height, left, width int) {
|
||||
// bracePairs is defined in buffer.go
|
||||
if buf.Settings["matchbrace"].(bool) {
|
||||
for _, bp := range bracePairs {
|
||||
r := buf.Cursor.RuneUnder(buf.Cursor.X)
|
||||
if r == bp[0] || r == bp[1] {
|
||||
if buf.Cursor.RuneUnder(buf.Cursor.X) == bp[0] {
|
||||
matchingBrace = buf.FindMatchingBrace(bp, buf.Cursor.Loc)
|
||||
break
|
||||
}
|
||||
left := buf.Cursor.Loc.X
|
||||
if buf.Settings["matchbraceleft"].(bool) {
|
||||
left -= 1
|
||||
if left < 0 {
|
||||
left = 0
|
||||
}
|
||||
}
|
||||
if buf.Cursor.RuneUnder(left) == bp[1] {
|
||||
matchingBrace = buf.FindMatchingBrace(
|
||||
bp, Loc{X: left, Y: buf.Cursor.Loc.Y})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +215,7 @@ func DefaultGlobalSettings() map[string]interface{} {
|
||||
"keepautoindent": false,
|
||||
"keymenu": false,
|
||||
"matchbrace": false,
|
||||
"matchbraceleft": false,
|
||||
"mouse": true,
|
||||
"pluginchannels": []string{"https://raw.githubusercontent.com/micro-editor/plugin-channel/master/channel.json"},
|
||||
"pluginrepos": []string{},
|
||||
@@ -257,6 +258,7 @@ func DefaultLocalSettings() map[string]interface{} {
|
||||
"indentchar": " ",
|
||||
"keepautoindent": false,
|
||||
"matchbrace": false,
|
||||
"matchbraceleft": false,
|
||||
"rmtrailingws": false,
|
||||
"ruler": true,
|
||||
"savecursor": false,
|
||||
|
||||
Reference in New Issue
Block a user