|
|
|
@ -20,46 +20,46 @@ func handleTab(viewName string) error {
@@ -20,46 +20,46 @@ func handleTab(viewName string) error {
|
|
|
|
|
inputString, err := getInputString(viewName) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
// if you successfully get an input string, grab the last word from the string
|
|
|
|
|
ss := regexp.MustCompile(`[ #]`).Split(inputString, -1) |
|
|
|
|
s := ss[len(ss)-1] |
|
|
|
|
// create a variable in which to store the result
|
|
|
|
|
var resultSlice []string |
|
|
|
|
// if the word starts with a : its an emoji lookup
|
|
|
|
|
if strings.HasPrefix(s, ":") { |
|
|
|
|
resultSlice = getEmojiTabCompletionSlice(s) |
|
|
|
|
} else if strings.HasPrefix(s, "/") { |
|
|
|
|
generateCommandTabCompletionSlice() |
|
|
|
|
s = strings.Replace(s, "/", "", 1) |
|
|
|
|
resultSlice = getCommandTabCompletionSlice(s) |
|
|
|
|
} else { |
|
|
|
|
// if you successfully get an input string, grab the last word from the string
|
|
|
|
|
ss := regexp.MustCompile(`[ #]`).Split(inputString, -1) |
|
|
|
|
s := ss[len(ss)-1] |
|
|
|
|
// create a variable in which to store the result
|
|
|
|
|
var resultSlice []string |
|
|
|
|
// if the word starts with a : its an emoji lookup
|
|
|
|
|
if strings.HasPrefix(s, ":") { |
|
|
|
|
resultSlice = getEmojiTabCompletionSlice(s) |
|
|
|
|
} else if strings.HasPrefix(s, "/") { |
|
|
|
|
generateCommandTabCompletionSlice() |
|
|
|
|
s = strings.Replace(s, "/", "", 1) |
|
|
|
|
resultSlice = getCommandTabCompletionSlice(s) |
|
|
|
|
} else { |
|
|
|
|
if strings.HasPrefix(s, "@") { |
|
|
|
|
// now in case the word (s) is a mention @something, lets remove it to normalize
|
|
|
|
|
s = strings.Replace(s, "@", "", 1) |
|
|
|
|
} |
|
|
|
|
// now call get the list of all possible cantidates that have that as a prefix
|
|
|
|
|
resultSlice = getChannelTabCompletionSlice(s) |
|
|
|
|
if strings.HasPrefix(s, "@") { |
|
|
|
|
// now in case the word (s) is a mention @something, lets remove it to normalize
|
|
|
|
|
s = strings.Replace(s, "@", "", 1) |
|
|
|
|
} |
|
|
|
|
rLen := len(resultSlice) |
|
|
|
|
lcp := longestCommonPrefix(resultSlice) |
|
|
|
|
if lcp != "" { |
|
|
|
|
originalViewTitle := getViewTitle("Input") |
|
|
|
|
newViewTitle := "" |
|
|
|
|
if rLen >= 1 && originalViewTitle != "" { |
|
|
|
|
if rLen == 1 { |
|
|
|
|
newViewTitle = originalViewTitle |
|
|
|
|
} else if rLen <= 5 { |
|
|
|
|
newViewTitle = fmt.Sprintf("%s|| %s", originalViewTitle, strings.Join(resultSlice, " ")) |
|
|
|
|
} else if rLen > 5 { |
|
|
|
|
newViewTitle = fmt.Sprintf("%s|| %s +%d more", originalViewTitle, strings.Join(resultSlice[:6], " "), rLen-5) |
|
|
|
|
} |
|
|
|
|
setViewTitle(viewName, newViewTitle) |
|
|
|
|
remainder := stringRemainder(s, lcp) |
|
|
|
|
writeToView(viewName, remainder) |
|
|
|
|
// now call get the list of all possible cantidates that have that as a prefix
|
|
|
|
|
resultSlice = getChannelTabCompletionSlice(s) |
|
|
|
|
} |
|
|
|
|
rLen := len(resultSlice) |
|
|
|
|
lcp := longestCommonPrefix(resultSlice) |
|
|
|
|
if lcp != "" { |
|
|
|
|
originalViewTitle := getViewTitle("Input") |
|
|
|
|
newViewTitle := "" |
|
|
|
|
if rLen >= 1 && originalViewTitle != "" { |
|
|
|
|
if rLen == 1 { |
|
|
|
|
newViewTitle = originalViewTitle |
|
|
|
|
} else if rLen <= 5 { |
|
|
|
|
newViewTitle = fmt.Sprintf("%s|| %s", originalViewTitle, strings.Join(resultSlice, " ")) |
|
|
|
|
} else if rLen > 5 { |
|
|
|
|
newViewTitle = fmt.Sprintf("%s|| %s +%d more", originalViewTitle, strings.Join(resultSlice[:6], " "), rLen-5) |
|
|
|
|
} |
|
|
|
|
setViewTitle(viewName, newViewTitle) |
|
|
|
|
remainder := stringRemainder(s, lcp) |
|
|
|
|
writeToView(viewName, remainder) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -123,22 +123,23 @@ func getCurrentChannelMembership() []string {
@@ -123,22 +123,23 @@ func getCurrentChannelMembership() []string {
|
|
|
|
|
var rs []string |
|
|
|
|
if channel.Name != "" { |
|
|
|
|
t := k.NewTeam(channel.Name) |
|
|
|
|
if testVar, err := t.MemberList(); err != nil { |
|
|
|
|
testVar, err := t.MemberList() |
|
|
|
|
if err != nil { |
|
|
|
|
return rs // then this isn't a team, its a PM or there was an error in the API call
|
|
|
|
|
} else { |
|
|
|
|
for _, m := range testVar.Result.Members.Owners { |
|
|
|
|
rs = append(rs, fmt.Sprintf("%+v", m.Username)) |
|
|
|
|
} |
|
|
|
|
for _, m := range testVar.Result.Members.Admins { |
|
|
|
|
rs = append(rs, fmt.Sprintf("%+v", m.Username)) |
|
|
|
|
} |
|
|
|
|
for _, m := range testVar.Result.Members.Writers { |
|
|
|
|
rs = append(rs, fmt.Sprintf("%+v", m.Username)) |
|
|
|
|
} |
|
|
|
|
for _, m := range testVar.Result.Members.Readers { |
|
|
|
|
rs = append(rs, fmt.Sprintf("%+v", m.Username)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for _, m := range testVar.Result.Members.Owners { |
|
|
|
|
rs = append(rs, fmt.Sprintf("%+v", m.Username)) |
|
|
|
|
} |
|
|
|
|
for _, m := range testVar.Result.Members.Admins { |
|
|
|
|
rs = append(rs, fmt.Sprintf("%+v", m.Username)) |
|
|
|
|
} |
|
|
|
|
for _, m := range testVar.Result.Members.Writers { |
|
|
|
|
rs = append(rs, fmt.Sprintf("%+v", m.Username)) |
|
|
|
|
} |
|
|
|
|
for _, m := range testVar.Result.Members.Readers { |
|
|
|
|
rs = append(rs, fmt.Sprintf("%+v", m.Username)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return rs |
|
|
|
|
} |
|
|
|
|