Skip to content

Commit

Permalink
229280: Corrected regex for windows paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Parasaran-Python committed Oct 12, 2024
1 parent 826e1e6 commit 90d3db2
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SmartPasteUtils {
*/
static isPath(string: string): boolean {
// Regex to detect common path formats
const windowsPathPattern = /^[a-zA-Z]:\\/; // Windows absolute path
const windowsPathPattern = /^[a-zA-Z]:(\\|\/)/; // Windows absolute path
const uncPathPattern = /^\\\\/; // Windows UNC path
const unixPathPattern = /^\/|(\w+\/)/; // Unix/Linux/macOS paths

Expand Down Expand Up @@ -76,14 +76,17 @@ export async function shouldPasteTerminalText(accessor: ServicesAccessor, text:
// If the clipboard has only one line, a warning should never show
const textForLines = text.split(/\r?\n/);

const isSmartPasteAllowed = configurationService.getValue(TerminalSettingId.AllowSmartPaste);
// If the string is a path process it depending on the shell type
// multi line strings aren't handled
const modifiedText = SmartPasteUtils.handleSmartPaste(text, shellType);
let modifiedText = text;

if (isSmartPasteAllowed) {
modifiedText = SmartPasteUtils.handleSmartPaste(text, shellType);
}

if (textForLines.length === 1) {
return {
modifiedText: modifiedText
};
return text === modifiedText ? true : { modifiedText: modifiedText };
}

// Get config value
Expand Down

0 comments on commit 90d3db2

Please sign in to comment.