Skip to content

Commit 8b4cebc

Browse files
committed
nes: support <NO_EDIT> response and update post-script in user message
1 parent f6ac31d commit 8b4cebc

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/extension/xtab/common/promptCrafting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function getPostScript(strategy: PromptingStrategy | undefined, currentFilePath:
130130
postScript = `<|aggressive|>${aggressivenessLevel}<|/aggressive|>`;
131131
break;
132132
case PromptingStrategy.PatchBased:
133-
postScript = `Output a modified diff style format with the changes you want. Each change patch must start with \`<filename>:<line number>\` and then include some non empty "anchor lines" preceded by \`-\` and the new lines meant to replace them preceded by \`+\`. Put your changes in the order that makes the most sense, for example edits inside the code_to_edit region and near the user's <|cursor|> should always be prioritized.`;
133+
postScript = `Output a modified diff style format with the changes you want. Each change patch must start with \`<filename>:<line number>\` and then include some non empty "anchor lines" preceded by \`-\` and the new lines meant to replace them preceded by \`+\`. Put your changes in the order that makes the most sense, for example edits inside the code_to_edit region and near the user's <|cursor|> should always be prioritized. Output "<NO_EDIT>" if you don't have a good edit candidate.`;
134134
break;
135135
case PromptingStrategy.SimplifiedSystemPrompt:
136136
case PromptingStrategy.CopilotNesXtab:

src/extension/xtab/common/tags.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export namespace PromptTags {
3636
}
3737

3838
export namespace ResponseTags {
39+
export const NO_EDIT = '<NO_EDIT>';
40+
3941
export const NO_CHANGE = {
4042
start: '<NO_CHANGE>'
4143
};

src/extension/xtab/node/xtabCustomDiffPatchResponseHandler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { LineReplacement } from '../../../util/vs/editor/common/core/edits/lineE
1010
import { LineRange } from '../../../util/vs/editor/common/core/ranges/lineRange';
1111
import { OffsetRange } from '../../../util/vs/editor/common/core/ranges/offsetRange';
1212
import { StringText } from '../../../util/vs/editor/common/core/text/abstractText';
13+
import { ResponseTags } from '../common/tags';
1314

1415

1516
class Patch {
@@ -83,6 +84,9 @@ export class XtabCustomDiffPatchResponseHandler {
8384
let currentPatch: Patch | null = null;
8485
for await (const line of linesStream) {
8586
// if no current patch, try to parse a new one
87+
if (line.trim() === ResponseTags.NO_EDIT) {
88+
break;
89+
}
8690
if (currentPatch === null) {
8791
currentPatch = Patch.ofLine(line);
8892
continue;

0 commit comments

Comments
 (0)