-
Notifications
You must be signed in to change notification settings - Fork 23
fix: SSHConfig: check for multiple start/end blocks #510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
eda19a2
d5dfbfc
752a2a8
572a938
bcebbd4
a9265be
e65ee21
ca32d99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,3 +120,22 @@ export function expandPath(input: string): string { | |
const userHome = os.homedir() | ||
return input.replace(/\${userHome}/g, userHome) | ||
} | ||
|
||
/** | ||
* Return the number of times a substring appears in a string. | ||
* @param needle string | ||
* @param haystack string | ||
* @returns number | ||
johnstcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
export function countSubstring(needle: string, haystack: string): number { | ||
if (needle.length < 1 || haystack.length < 1) { | ||
return 0 | ||
} | ||
let count = 0 | ||
let pos = haystack.indexOf(needle) | ||
while (pos !== -1) { | ||
count++ | ||
pos = haystack.indexOf(needle, pos + needle.length) | ||
} | ||
return count | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this could be simplified, like so? return [...haystack.matchAll(needle)].length There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks way better, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah, forgot not all these methods are string | RegExp. That can be simply amended with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only available in Node 24 and current version of VSCode is on 23.11.0 if I'm not mistaken 🥲 |
||
} |
Uh oh!
There was an error while loading. Please reload this page.