Comments (3)
I'll get back to it soon.
from nwg-drawer.
I wrote two functions to correct the behavior:
func parseString(s string) []string {
var r = regexp.MustCompile(`(".*"|(\\\s|[^\s])+)`)
var res = r.FindAllString(s, -1)
return res
}
func parseString2(command string) []string {
var elements []string
var confirmed []string
if !strings.Contains(command, "\"") {
elements = append(elements, strings.Split(command, " ")...)
} else {
for strings.Contains(command, "\"") {
quoteSplit := strings.SplitN(command, "\"", 2)
elements = append(elements, strings.Split(quoteSplit[0], " ")...)
quoteSplit = strings.SplitN(quoteSplit[1], "\"", 2)
elements = append(elements, quoteSplit[0])
command = quoteSplit[1]
}
}
for i := 0; i < len(elements); i++ {
if elements[i] != "" { // Ignore empty arguments
element := elements[i]
// If the argument end with "\ " then merge with next argument
for element[len(element)-1] == '\\' {
element = strings.Replace(element, "\\", "", 1)
element = element + " " + elements[i+1]
i++
}
confirmed = append(confirmed, element)
}
}
return confirmed
}
Both seem to work fine in my testing but checking edge cases may be necessary, I don't like the second one as it is a little convoluted but running benchmarks proved that it is much faster than the regex option.
from nwg-drawer.
I also encountered this issue in nwg-menu. This seems important!
from nwg-drawer.
Related Issues (20)
- Dead icons in nwg-drawer HOT 5
- Dotted lines not in drawer.css HOT 3
- nwg-drawer send string to search from command line HOT 5
- Can't click on waybar when nwg-drawer is open HOT 3
- Categories not showing HOT 14
- [CHANGED BEHAVIOR] New installation opens default list differently, can't fix HOT 6
- Uninstalled apps impossible to unpin HOT 1
- Drawer not following CSS with newest update HOT 2
- New option --config HOT 1
- /tmp/nwg-drawer.lock was owned by other user HOT 1
- nwg-drawer upgrade from 0.2.8 to 0.3.0 broke HOT 1
- Non-ascii character problem in menu name shortening HOT 6
- Specify icon theme HOT 7
- Panic when run pkill -USR1 nwg-drawer HOT 6
- Launching thunar from nwg-drawer opens in sway config directory HOT 2
- feature: prefer most used applications HOT 1
- Add CI HOT 2
- Launching certain apps HOT 10
- Change term overriding variable and improve error handling? HOT 4
- Some icons appear smaller and are offset when searching HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nwg-drawer.