summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkText.c8
-rw-r--r--tests/textDisp.test10
2 files changed, 16 insertions, 2 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index 2c4d54c..9cae716 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -1508,8 +1508,14 @@ TextWidgetObjCmd(
result = TkTextXviewCmd(textPtr, interp, objc, objv);
break;
case TEXT_YUPDATE: {
- if ((objc == 4) && !strncmp(Tcl_GetString(objv[2]), "-command", objv[3]->length)) {
+ if (objc == 4) {
Tcl_Obj *cmd = objv[3];
+ const char *option = Tcl_GetString(objv[2]);
+ if (strncmp(option, "-command", objv[2]->length)) {
+ Tcl_AppendResult(interp, "wrong option \"", option, "\": should be \"-command\"", NULL);
+ result = TCL_ERROR;
+ goto done;
+ }
Tcl_IncrRefCount(cmd);
if (TkTextPendingyupdate(textPtr)) {
if (textPtr->linesUpdatedCmd) {
diff --git a/tests/textDisp.test b/tests/textDisp.test
index f2b176c..133fcf5 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -4201,9 +4201,17 @@ test textDisp-34.2 {text yupdate syntax} -body {
test textDisp-34.3 {text yupdate syntax} -body {
} -body {
+ pack [text .t1] -expand 1 -fill both
+ .t1 yupdate -comx foo
+} -cleanup {
+ destroy .t1
+} -returnCodes 1 -result {wrong option "-comx": should be "-command"}
+
+test textDisp-34.4 {text yupdate syntax} -body {
+} -body {
set ::x 0
pack [text .t1] -expand 1 -fill both
- .t1 yupdate -command [list set ::x 1]
+ .t1 yupdate -comm [list set ::x 1]
set ::x
} -cleanup {
destroy .t1