Kevin van Dijk 1 місяць тому
батько
коміт
8e80dfc0a7

+ 11 - 1
src/core/ignore/RooIgnoreController.ts

@@ -4,6 +4,7 @@ import fs from "fs/promises"
 import fsSync from "fs"
 import ignore, { Ignore } from "ignore"
 import * as vscode from "vscode"
+import "../../utils/path" // Import to enable String.prototype.toPosix()
 
 export const LOCK_TEXT_SYMBOL = "\u{1F512}"
 
@@ -128,7 +129,12 @@ export class RooIgnoreController {
 
 		// Split command into parts and get the base command
 		const parts = command.trim().split(/\s+/)
-		const baseCommand = parts[0].toLowerCase()
+		const baseCommand = parts[0]?.toLowerCase()
+
+		// If no base command, allow the command
+		if (!baseCommand) {
+			return undefined
+		}
 
 		// Commands that read file contents
 		const fileReadingCommands = [
@@ -153,6 +159,10 @@ export class RooIgnoreController {
 			// Check each argument that could be a file path
 			for (let i = 1; i < parts.length; i++) {
 				const arg = parts[i]
+				// Skip undefined arguments
+				if (!arg) {
+					continue
+				}
 				// Skip command flags/options (both Unix and PowerShell style)
 				if (arg.startsWith("-") || arg.startsWith("/")) {
 					continue

+ 3 - 2
src/services/ripgrep/index.ts

@@ -7,6 +7,7 @@ import * as vscode from "vscode"
 import { RooIgnoreController } from "../../core/ignore/RooIgnoreController"
 import { fileExistsAtPath } from "../../utils/fs"
 import { checkBunPath } from "./index.kilocode" // kilocode_change
+import "../../utils/path" // Import to enable String.prototype.toPosix()
 /*
 This file provides functionality to perform regex searches on files using ripgrep.
 Inspired by: https://github.com/DiscreteTom/vscode-ripgrep-utils
@@ -195,11 +196,11 @@ export async function regexSearchFiles(
 					}
 
 					const lastResult = currentFile.searchResults[currentFile.searchResults.length - 1]
-					if (lastResult?.lines.length > 0) {
+					if (lastResult?.lines && lastResult.lines.length > 0) {
 						const lastLine = lastResult.lines[lastResult.lines.length - 1]
 
 						// If this line is contiguous with the last result, add to it
-						if (parsed.data.line_number <= lastLine.line + 1) {
+						if (lastLine && parsed.data.line_number <= lastLine.line + 1) {
 							lastResult.lines.push(line)
 						} else {
 							// Otherwise create a new result

+ 1 - 1
src/services/roo-config/index.ts

@@ -185,7 +185,7 @@ export async function discoverSubfolderRooDirectories(cwd: string): Promise<stri
 			// Match paths like "subfolder/.roo/anything" or "subfolder/nested/.roo/anything"
 			// Handle both forward slashes (Unix) and backslashes (Windows)
 			const match = result.path.match(/^(.+?)[/\\]\.roo[/\\]/)
-			if (match) {
+			if (match && match[1]) {
 				const rooDir = path.join(cwd, match[1], ".roo")
 				// Exclude the root .roo directory (already handled by getProjectRooDirectoryForCwd)
 				if (rooDir !== rootRooDir) {

+ 1 - 0
src/services/search/file-search.ts

@@ -6,6 +6,7 @@ import * as readline from "readline"
 import { byLengthAsc, Fzf } from "fzf"
 import { getBinPath } from "../ripgrep"
 import { Package } from "../../shared/package"
+import "../../utils/path" // Import to enable String.prototype.toPosix()
 
 export type FileResult = { path: string; type: "file" | "folder"; label?: string }
 

+ 5 - 2
src/utils/fs.ts

@@ -24,8 +24,11 @@ export async function createDirectoriesForFile(filePath: string): Promise<string
 
 	// Create directories from the topmost missing one down to the target directory
 	for (let i = dirsToCreate.length - 1; i >= 0; i--) {
-		await fs.mkdir(dirsToCreate[i])
-		newDirectories.push(dirsToCreate[i])
+		const dirPath = dirsToCreate[i]
+		if (dirPath) {
+			await fs.mkdir(dirPath)
+			newDirectories.push(dirPath)
+		}
 	}
 
 	return newDirectories