Replace StringRange w/ an actual StrRVal + more command implementations
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Command, ParseContext, StrTerm} from "./command.js";
|
||||
import {Command, ParseContext, StrTerm, unwrapString, wrapString} from "./command.js";
|
||||
import {LexInput} from "../lexer.js";
|
||||
import {StrVM} from "../vm.js";
|
||||
import {Awaitable} from "../../util/types.js";
|
||||
@@ -25,14 +25,13 @@ export class Enclose extends Command<EncloseData> {
|
||||
}
|
||||
|
||||
execute(vm: StrVM, data: EncloseData): Awaitable<StrVM> {
|
||||
return vm.inPlace(ctx => {
|
||||
return vm.tapInPlace(ctx => {
|
||||
const [left, right] = this.determineSurroundingStrings(
|
||||
data.left ? ctx.resolveString(data.left) : undefined,
|
||||
data.right ? ctx.resolveString(data.right) : undefined,
|
||||
)
|
||||
|
||||
return ctx.replaceSubject(sub =>
|
||||
sub.modify(s => `${left}${s}${right}`))
|
||||
return ctx.replaceSubjectAsString(sub => `${left}${sub}${right}`)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user