Skip to content

Instantly share code, notes, and snippets.

@nocd5
Created June 24, 2015 12:45
Show Gist options
  • Save nocd5/0baa68cfa9a769151889 to your computer and use it in GitHub Desktop.
Save nocd5/0baa68cfa9a769151889 to your computer and use it in GitHub Desktop.
the_platinum_searcherの/columnの出力をbyteから文字数に変更するパッチ
diff --git a/match.go b/match.go
index 939724e..e17cf14 100644
--- a/match.go
+++ b/match.go
@@ -51,9 +51,9 @@ func (m *Match) setMatch(pattern *Pattern, num int, s string) {
m.Line.Str = s
if m.setCol {
if pattern.UseRegexp || pattern.IgnoreCase {
- m.Col = pattern.Regexp.FindStringIndex(m.Str)[0] + 1
+ m.Col = len([]rune(m.Str[0:pattern.Regexp.FindStringIndex(m.Str)[0]])) + 1
} else {
- m.Col = strings.Index(m.Str, pattern.Pattern) + 1
+ m.Col = len([]rune(m.Str[0:strings.Index(m.Str, pattern.Pattern)])) + 1
}
}
m.Matched = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment