Created
June 24, 2015 12:45
-
-
Save nocd5/0baa68cfa9a769151889 to your computer and use it in GitHub Desktop.
the_platinum_searcherの/columnの出力をbyteから文字数に変更するパッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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