Skip to content

Commit

Permalink
1.2.20
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski committed Nov 18, 2024
1 parent 3a2ec5e commit 807e091
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ fun SocketManagerBase.addApplyFileDiffLinks(
val findAll = codeblockPattern.findAll(response).toList()
val codeblocks = findAll.filter { block ->
try {
val header = headers.lastOrNull { it.first.last <= block.range.first } ?: defaultFile?.let { IntRange(0,0) to it }
val header = headers.lastOrNull { it.first.last <= block.range.first }?.let { it.second } ?: defaultFile
if (header == null) {
return@filter false
}
val filename = resolve(root, header.second)
val filename = resolve(root, header)
!root.resolve(filename).toFile().exists()
} catch (e: Throwable) {
log.info("Error processing code block", e)
Expand All @@ -66,11 +66,11 @@ fun SocketManagerBase.addApplyFileDiffLinks(
}.map { it.range to it }.toList()
val patchBlocks = findAll.filter { block ->
try {
val header = headers.lastOrNull { it.first.last <= block.range.first } ?: defaultFile?.let { IntRange(0,0) to it }
val header = headers.lastOrNull { it.first.last <= block.range.first }?.let { it.second } ?: defaultFile
if (header == null) {
return@filter false
}
val filename = resolve(root, header.second)
val filename = resolve(root, header)
root.resolve(filename).toFile().exists()
} catch (e: Throwable) {
log.info("Error processing code block", e)
Expand Down Expand Up @@ -127,7 +127,7 @@ fun SocketManagerBase.addApplyFileDiffLinks(
// Process diff blocks and add patch links
val withPatchLinks: String = patchBlocks.foldIndexed(response) { index, markdown, diffBlock ->
val value = diffBlock.second.groupValues[2].trim()
var header = headers.lastOrNull { it.first.last < diffBlock.first.first }?.second ?: "Unknown"
var header = headers.lastOrNull { it.first.last < diffBlock.first.first }?.second ?: defaultFile ?: "Unknown"
header = corrections?.get("patch_$index") ?: header
val filename = resolve(root, header)
val newValue = renderDiffBlock(root, filename, value, handle, ui, api, shouldAutoApply)
Expand All @@ -137,7 +137,7 @@ fun SocketManagerBase.addApplyFileDiffLinks(
val withSaveLinks = codeblocks.foldIndexed(withPatchLinks) { index, markdown, codeBlock ->
val lang = codeBlock.second.groupValues[1]
val value = codeBlock.second.groupValues[2].trim()
var header = headers.lastOrNull { it.first.last < codeBlock.first.first }?.second
var header = headers.lastOrNull { it.first.last < codeBlock.first.first }?.second ?: defaultFile ?: "Unknown"
header = corrections?.get("code_$index") ?: header
val newMarkdown = renderNewFile(header, root, ui, shouldAutoApply, value, handle, lang)
markdown.replace(codeBlock.second.value, newMarkdown)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ open class TabbedDisplay(

val size: Int get() = tabs.size
val tabId = UUID.randomUUID()
open fun render() = if (tabs.isEmpty()) "<div/>" else {
private fun render() = if (tabs.isEmpty()) "<div/>" else {
"""
<div class="tabs-container" id="$tabId">
${renderTabButtons()}
Expand All @@ -32,7 +32,7 @@ open class TabbedDisplay(
task.add(render())!!
}

open fun renderTabButtons() = """
protected open fun renderTabButtons() = """
<div class="tabs">${
tabs.toTypedArray().withIndex().joinToString("\n") { (idx, pair) ->
if (idx == selectedTab) {
Expand All @@ -44,7 +44,7 @@ open class TabbedDisplay(
}</div>
"""

open fun renderContentTab(t: Pair<String, StringBuilder>, idx: Int) = """
protected open fun renderContentTab(t: Pair<String, StringBuilder>, idx: Int) = """
<div class="tab-content ${
when {
idx == selectedTab -> "active"
Expand Down

0 comments on commit 807e091

Please sign in to comment.